Self-written function to solve the problem of pathinfo() function processing Chinese,
I encountered a small problem when writing a program today. Pathinfo has a problem when processing Chinese file names. If Chinese is at the beginning of the prefix, the obtained filename will be empty. If English is followed by Chinese at the beginning, it can be obtained. As shown below:
So I wrote a function instead. The code is as follows:
Copy code The code is as follows:
function path_info($filepath)
{
$path_parts = array();
$path_parts ['dirname'] = rtrim(substr($filepath, 0, strrpos($filepath, '/')),"/")."/";
$path_parts ['basename'] = ltrim(substr($filepath, strrpos($filepath, '/')),"/");
$path_parts ['extension'] = substr(strrchr($filepath, '.'), 1);
$path_parts ['filename'] = ltrim(substr($path_parts ['basename'], 0, strrpos($path_parts ['basename'], '.')),"/");
Return $path_parts;
}
The problem is solved
http://www.bkjia.com/PHPjc/904917.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/904917.htmlTechArticleSelf-written function to solve the problem of Chinese language processing of pathinfo() function. Today I encountered a small problem when writing a program. Pathinfo is in Problems that arise when processing Chinese file names. If Chinese is at the beginning of the word, it will appear...