ltrim() ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jcafaro10
Forum Newbie
Posts: 9
Joined: Tue Jan 05, 2010 11:44 am

ltrim() ?

Post by jcafaro10 »

I'm trying to use the ltrim function but getting an error.

Here's my code:
$line = ltrim($line,"../music/");
I just want to remove "../music/" from some text.

Getting this warning:

Code: Select all

Warning: ltrim() [function.ltrim]: Invalid '..'-range, no character to the left of '..' in C:\xampp\htdocs\music3.php on line 3
User avatar
manohoo
Forum Contributor
Posts: 201
Joined: Wed Dec 23, 2009 12:28 pm

Re: ltrim() ?

Post by manohoo »

jcafaro10
Forum Newbie
Posts: 9
Joined: Tue Jan 05, 2010 11:44 am

Re: ltrim() ?

Post by jcafaro10 »

actually thats not true, the link you sent specifies that it will remove characters as well. The ltrim function does remove what I need it to but it throws that warning, I'm not sure what it means or why its being thrown.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: ltrim() ?

Post by AbraCadaver »

The second parameter is a character list and the .. means a range, such as a..z would strip characters from a to z. Assuming that you just want the filename, I would use basename().
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
jcafaro10
Forum Newbie
Posts: 9
Joined: Tue Jan 05, 2010 11:44 am

Re: ltrim() ?

Post by jcafaro10 »

I'll look into basename(). How can I actually remove ".." then?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: ltrim() ?

Post by AbraCadaver »

jcafaro10 wrote:I'll look into basename(). How can I actually remove ".." then?
Several ways, substr_replace(), str_replace()... But if you want the filename portion of a path then that's what basename() is meant for.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply