more on portfolio









August 2008
M T W T F S S
« May «-»  
 123
45678910
11121314151617
18192021222324
25262728293031






 

Convert to Roman numbers in PHP

Log entry of May 4th 2008 05:51:24 pm
Filed under: PHP, Snippets
Here’s a nifty coding which I’ve found on the net on displaying Roman number like I II III IV etc.

<?php // A function to return the Roman Numeral, given an integer private function numberToRoman($num) { // Make sure that we only use the integer portion of the value $n = intval($num); $result = ”; // Declare a lookup array that we will use to traverse the number: $lookup = array(’M’ => 1000, ‘CM’ => 900, ‘D’ => 500, …

How to: Delete a folder with all files inside

Log entry of August 28th 2007 05:26:08 pm
Filed under: PHP, Snippets
We all know we can find a PHP code to delete a directory, but to delete a directory will thousands and millions of files in it? Here’s the coding which is quite a hassle to find, and I’m sharing it with y’all. function del_dir($dir) { $res = @opendir($dir);if(!$res) return; while(($file = readdir($res)) !== false) { if($file !== ‘.’ && $file !== ‘..’) { $f = $dir . ‘/’ . $file; if(is_dir($f)) { del_dir($f); } else { @unlink($f); } } } closedir($res); @rmdir($dir); } Save the code above to a single PHP file …