The file directory operation of the PHP surface question,
Get file suffix, traverse directory hierarchy
/** * 5 ways to get the file suffix name * This problem is actually the test function substr () STRRCHR () Array_pop () Strrpos () Strpos () Strrev () explode () pathinfo () * @param s Tring $filename The file name 1.jpg/1.png/1.html/1.php* @return string to process. php/php*/functionGET_EXT1 ($filename){ return STRRCHR($filename,'.');}functionGET_EXT2 ($filename){ return substr($filename,Strrpos($filename,'.'));}functionGET_EXT3 ($filename){ return Array_pop(Explode('.',$filename));}functionGET_EXT4 ($filename){ return PathInfo($filename,pathinfo_extension);}functionGET_EXT5 ($filename){ return Strrev(substr(Strrev($filename), 0,Strpos(Strrev($filename),'.')));}$filename= "1.php";EchoGET_EXT1 ($filename)." \ n ";EchoGET_EXT2 ($filename)." \ n ";EchoGET_EXT3 ($filename)." \ n ";EchoGET_EXT4 ($filename)." \ n ";EchoGET_EXT5 ($filename)." \ n ";
/** * Traverse directory (Recursive) * @param string $dir directory name and finally no/* @return array $files Entire directory structure*/functionMyscandir ($dir){ $files=Array(); if($handle=Opendir($dir)){ while(($file=Readdir($handle)) !=false){ if($file! = "." &&$file!= ".."){ $newDir=$dir." /".$file; if(Is_dir($newDir)){ $files[$file] = Myscandir ($newDir); }Else{ $files[] =$file; } } } Closedir($handle); return $files; }}$dir= "/dirname";Print_r(Myscandir ($dir));
http://www.bkjia.com/PHPjc/1060690.html www.bkjia.com true http://www.bkjia.com/PHPjc/1060690.html techarticle PHP surface of the file directory operation, get the file suffix, traverse the directory Hierarchy/* * * * * * * * * * 5 ways to get the file suffix name * This problem is actually the test function substr () STRRCHR () Array_pop () STRRP ...