PHP: Convert while loop in array -
how convert below result array? want make array can assign variable , use it
if($handle = opendir($path)){ while(false != ($filename = readdir($handle))) { if($filename != "." && $filename != ".."){ $name = preg_replace("/\\.[^.\\s]{3,4}$/", "", $filename); $name = str_replace('_', ' ', $name); $name = ucwords($name); echo $name; } } closedir($handle); }
simply add names array....
$files = array(); if($handle = opendir($path)){ while(false != ($filename = readdir($handle))) { if($filename != "." && $filename != ".."){ $name = preg_replace("/\\.[^.\\s]{3,4}$/", "", $filename); $name = str_replace('_', ' ', $name); $name = ucwords($name); $files[] = $name; } } closedir($handle); }
Comments
Post a Comment