Jump to content

Archived

This topic is now archived and is closed to further replies.

phporcaffeine

string problems

Recommended Posts


$data = "bin/IT_Department/ryan.vpg";

$trm = ltrim (strtolower($directory), "bin/");

echo $trm;

//RESULT IS:

"t_department/ryan.vpg";

Why is it taking the " I " along with " bin/ "?

PLEASE HELP!@#, lol

TIA

Share this post


Link to post
Share on other sites
because "I" is in your strip list :-)

[a href=\"http://us3.php.net/ltrim\" target=\"_blank\"]http://us3.php.net/ltrim[/a]

Share this post


Link to post
Share on other sites
if you're after exact matching like that, why not use str_replace or preg_replace instead?

[code]
$data = "bin/IT_Department/ryan.vpg";
$data = str_replace("bin/", "", $data);
echo $data;
[/code]

Share this post


Link to post
Share on other sites
Call it a moment of absentism but I was trying to do a regex match with ltrim() thats why it was confusing me. As suggested, I fixed the issue with str_replace.

Share this post


Link to post
Share on other sites
.. or

[code]$data = "bin/IT_Department/ryan.vpg";
$data = substr($data, 4);[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.