I needed to remove a tag and all the text within a tag. Sounds easy enough. Here is the HTML: $content = ‘Hello <div id=”tag_to_remove”>I […]
Continue readingCategory: PHP
PHP
file_put_contents() Function for PHP 4
I needed to run code I wrote for PHP 5 on a PHP 4 installation. Everything worked except the file_put_contents function. I scoured the web […]
Continue readingFunction to Create an Array from Database Results in PHP
This simple function will create an array out of the multi-dimensional rows returned from a database query. function mysql_fetch_array_r($result,$result_type=MYSQL_NUM) { $arr = array(); for($i=0;$i<@mysql_num_rows($result);$i++) { […]
Continue readingFunction to Format a Date in PHP
This is a really simple function to format a date. function date_formatter($date) { return date(“Y-m-d G:i:s”,$date); }
Continue readingOutput File Size in PHP
Pass a file size to this function like this: $filesize = get_file_size(2048); And return a nicely formatted file size: 2 MB // function to get […]
Continue reading