0
$individual_file["uri"] = "public://iStock_000000527255XSmall.jpg";
print_r(ltrim($individual_file["uri"], "public://"));

Result -: Stock_000000527255XSmall.jpg

为什么缺少我?但是当我的角色以 si 开头时,我会在结果中得到 si。为什么修剪的行为不同?

$individual_file["uri"] = "public://siStock_000000527255XSmall.jpg";
print_r(ltrim($individual_file["uri"], "public://"));

Result -: siStock_000000527255XSmall.jpg
4

1 回答 1

5

It's because charlist is literally a list of single characters to remove from the left side of the string and i is listed in public://. Any character that falls in this list will be removed, no matter the order.

Ref: http://php.net/manual/en/function.ltrim.php

In fact this:

$individual_file["uri"] = "public://iStock_000000527255XSmall.jpg";
print_r(ltrim($individual_file["uri"], "publc://"));

would output:

ic://iStock_000000527255XSmall.jpg

Another example by changing the order:

$individual_file["uri"] = "public://iStock_000000527255XSmall.jpg";
print_r(ltrim($individual_file["uri"], "bcilpu:/"));

would output:

Stock_000000527255XSmall.jpg
于 2013-10-06T07:52:32.497 回答