In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
The editor will share with you the example analysis of the file directory operation of the PHP interview questions. I hope you will get something after reading this article. Let's discuss it together.
In fact, this question is not difficult, the test site is mainly in the function substr () strrchr () array_pop () strrpos () strpos () strrev () explode () pathinfo ().
Get the file suffix and traverse the directory hierarchy
/ * 5 ways to get the file suffix * this question is actually a test of the function substr () strrchr () array_pop () strrpos () strrpos () strpos () strrev () explode () pathinfo () * @ param string $filename the file name 1.jpg _ filename 1.png _ filename 1.html _ 1.php * @ return string .php / php* / function get_ext1 ($filename) {return strrchr ($filename,'.') } function get_ext2 ($filename) {return substr ($filename,strrpos ($filename,'.'));} function get_ext3 ($filename) {return array_pop (explode ('.', $filename));} function get_ext4 ($filename) {return pathinfo ($filename,PATHINFO_EXTENSION);} function get_ext5 ($filename) {return strrev (substr (strrev ($filename), 0memery strpos (strrev ($filename),'.'));} $filename = "1.php"; echo get_ext1 ($filename). "\ n" Echo get_ext2 ($filename). "\ n"; echo get_ext3 ($filename). "\ n"; echo get_ext4 ($filename). "\ n"; echo get_ext5 ($filename). "\ n"; / * traversal directories (recursive) * @ param string $dir directory name and finally no / * @ return array $files entire directory structure * / function myScandir ($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)) After reading this article, I believe you have a certain understanding of "sample analysis of file directory operation of PHP interview questions". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for your reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.