Jump to content


Photo

string problems


  • Please log in to reply
4 replies to this topic

#1 phporcaffeine

phporcaffeine
  • Members
  • PipPipPip
  • Advanced Member
  • 361 posts
  • LocationOhio, USA

Posted 09 May 2006 - 05:47 PM


$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
Thanks,

Ryan Huff
President & Founder, MyCodeTree
support@mycodetree.com | http://mycodetree.com

#2 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 09 May 2006 - 06:26 PM

because "I" is in your strip list :-)

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

#3 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 09 May 2006 - 06:32 PM

if you're after exact matching like that, why not use str_replace or preg_replace instead?

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

You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#4 phporcaffeine

phporcaffeine
  • Members
  • PipPipPip
  • Advanced Member
  • 361 posts
  • LocationOhio, USA

Posted 09 May 2006 - 07:02 PM

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.
Thanks,

Ryan Huff
President & Founder, MyCodeTree
support@mycodetree.com | http://mycodetree.com

#5 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 09 May 2006 - 08:32 PM

.. or

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

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users