Welcome To Snipplr
Everyone's Recent PHP Snippets Tagged convert
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
I can't say I can rely on mb_detect_encoding(). Had some freaky false positives a while back. The following code will detect when you need to enconde or decode it.
1
991
posted 9 years ago by fackz
This function takes HTML input and converts it to plain text. It needs improvement so that it converts multiple blank lines to a single blank line and converts an <a ... > link to the markup equivalent (same for images). It should be rewritten...
0
1171
posted 10 years ago by nigelnquande
This snippets converts a file called 'test.mp3' in the same folder, to a file called 'test.ogg' and saves it in the same folder as well
0
1735
posted 10 years ago by dragoviandesign
This function returns the duration of the given time period in days, hours, minutes and seconds. For example: echo convertSecToStr('654321'); would return "7 days, 13 hours, 45 minutes, 21 seconds"
0
1024
posted 11 years ago by apphp-snippets
This useful function will convert a time in seconds to a time in years, months, weeks, days, and so on.
0
1710
posted 11 years ago by goo
Convert 12-hour time format with hour, minutes, seconds, and meridiem into 24-hour format. Performs data correction to make sure hours, minutes and seconds have leading zeros if needed.
The trick here is to use strtotime() where we pass the time...
0
4107
posted 12 years ago by kosinix
For those cases where you want to code in PHP but need to deploy to ASP. It doesn't account for php logic but only converts the php include() statements into SSI includes. Could be useful for converting basic websites from php to asp, rare but it hap...
0
1102
posted 12 years ago by crypticsoft
This PHP code is made to help people using the ActionScript 3 AlivePDF library to save PDF files from a Flash app to a server.
ActionScript 3 AlivePDF save code:
_pdf.save(Method.REMOTE, "save.php", Download.ATTACHMENT, "MyFile.pdf");
0
1033
posted 12 years ago by vamapaull
This code is applied from http://www.ultramegatech.com/blog/2009/06/snippet-converting-seconds-to-readable-time/
0
796
posted 12 years ago by zierocode
This function accept one parameter (integer or float) and returns the same number writed with words. Useful for currencies and invoices.
0
1009
posted 13 years ago by stz184
This is a very rudimentary function used to convert a Datetime delivered by the Twitter API to a format you can store in MySQL's datetime field.
0
1522
posted 13 years ago by aristoworks
Sometimes a legacy database will have HTML entities stored in it.
This function converts them. Note that this function assumes you have a database abstraction layer, and may need to be modified to connect to YOUR database.
0
2286
posted 13 years ago by f6design
Takes a number (no decimal) and converts it to written words.Why'd i write it to be able to do such big numbers? Why not?
Note: The numbers next to the 'thousandfoldnums' are for your reference (thats how many zeros/places there are in that numbe...
0
1014
posted 13 years ago by lasavior
This simply takes an array and coverts it to variables. E.g. If you had an array, $array = array("key" => "value"), after running this script, $key would be "value".
0
772
posted 13 years ago by mloberg
This method is easy to write, but not very efficient, as you can imagine.
2
1378
posted 14 years ago by dyteq
This will convert dates from MM-DD-YYYY to YYYY-MM-DD (iso format)
1
1124
posted 14 years ago by bradless