Self-coding function solves PathInfo () function to handle Chinese problem, _php tutorial

Source: Internet
Author: User

The self-coding function solves the Chinese problem with the PathInfo () function.


Today to write the program encountered a small problem, pathinfo in the processing of Chinese file name problems, if the Chinese in the beginning of the word to get the filename is empty, English at the beginning of the word after the Chinese can be obtained. Such as:

So I wrote a function instead, the code is as follows:

Copy the Code code 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;
}

So the problem is solved.




http://www.bkjia.com/PHPjc/904917.html www.bkjia.com true http://www.bkjia.com/PHPjc/904917.html techarticle The self-function solves the PathInfo () function to handle the Chinese question, today writes the program to encounter a small problem, pathinfo in the processing Chinese file name the problem, if the Chinese in the word first appears to obtain ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.