May Have Discovered a Bug; Requesting Feedback

General discussions related to php

Moderators: egami, macek, gesf

Post Reply
landi
php-forum Active User
php-forum Active User
Posts: 388
Joined: Thu Mar 15, 2012 3:59 pm

Fri Aug 29, 2014 2:44 pm

Hi,
<jedi>These are not the functions you are looking for</jedi>

The trim functions are not parsing function. They trim any character in str2 from the beginning and or end of str1. So:

Code: Select all

echo ltrim('a/b/c.zip', 'a/b/c'); 
will output .zip. So will:

Code: Select all

echo ltrim('a/b/c.zip', 'bca/'); 
because str2 is just a list of chars, not a regex or anything. The reason it works for a capitalised name is because you don't have the capital letter in the list of chars i.e.:

Code: Select all

echo ltrim('a/b/C.zip', 'a/b/c'); 
will output C.zip as will:

Code: Select all

echo ltrim('a/b/cccC.zip', 'a/b/c'); 
but

Code: Select all

echo ltrim('a/b/cccC.zip', 'a/b/c/C');
will output just .zip

Perhaps you wanted basename() or pathinfo() or one of the other PHP filename parsing functions. :)

-Ob1

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests