Ltrim () function solution

Source: Internet
Author: User
For more information about the ltrim () function, php experts, why can't I get the desired result about the ltrim () function? Let's take a look at the code. $ str1 = "E:/xmapp/htdocs/mycode/cms/"; $ str2 = "E:/xmapp/htdocs /"; about ltrim () functions
Dear php experts, why can't I get the desired result about the ltrim () function? Let's take a look at the code.

$str1="E:/xmapp/htdocs/mycode/mycode/cms/";
$str2="E:/xmapp/htdocs/";
echo ltrim($str1,$str2)."
";

The output result of running code is:
Ycode/mycode/cms/
Expected code output result;
Mycode/cms/

The second code:

$str3="e:/hell/ab/mycode/cms";
$str4="e:/hell/ab/";
echo ltrim($str3,$str4)."
";


The output result of running code is:
Mycode/cms
Expected code output result;
Mycode/cms



Ladies and gentlemen: Why is the expectation of the first code different from that of the actual output code, while the expectation of the second code is the same as that of the actual code (note: the two codes run independently without additional code)

------ Solution --------------------
I really don't know how your Chinese teacher taught you?

The charlist parameter specifies which characters are deleted from the string.
Note: Character, No String

If you do not understand Chinese, you should also understand English.
Strip whitespace (or other characters) from the beginning of a string
Strip stripping
Whitespace (or other characters) blank (or other characters)
From the beginning of a string starts with a string

Charlist character list
You also need to learn how to understand the function usage from the function prototype.

For ltrim ($ str1, $ str2)
Scan $ str1 and delete the characters that appear in $ str2 one by one until they appear outside $ str2.

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.