[Phpwm] ltrin inconsistency

Phil Beynon phil at infolinkelectronics.co.uk
Thu Jul 27 19:07:31 BST 2006


Has anyone seen or know the answer to this apparent inconsistency with the
ltrim() command;
I'm storing some image names in a database, these have prepended to them a
directory path which when displaying just the filename needs to be dropped.
So what I did was this;

ltrim($myrow["thumb_name"],"./75px/");
ltrim($myrow["large_name"],"./150px/");
ltrim($myrow["big_name"],"./250px/");

which as far as I can should work, generally it does - but for some reason
its not consistent but appears to stabily inconsistent;

These ones work just fine;

full = ./75px/tn_e2cc_3.jpg trimmed = tn_e2cc_3.jpg
full = ./150px/e2cc_3.jpg trimmed = e2cc_3.jpg
full = ./250px/e2cc_3.jpg trimmed = e2cc_3.jpg

full = ./75px/tn_6e57_chick.jpg trimmed = tn_6e57_chick.jpg
full = ./150px/6e57_chick.jpg trimmed = 6e57_chick.jpg
full = ./250px/6e57_chick.jpg trimmed = 6e57_chick.jpg

full = ./75px/tn_8139_phil3.JPG trimmed = tn_8139_phil3.JPG
full = ./150px/8139_phil3.JPG trimmed = 8139_phil3.JPG
full = ./250px/8139_phil3.JPG trimmed = 8139_phil3.JPG

full = ./75px/tn_ada8_james.JPG trimmed = tn_ada8_james.JPG
full = ./150px/ada8_james.JPG trimmed = ada8_james.JPG
full = ./250px/ada8_james.JPG trimmed = ada8_james.JPG

This one always loses either the "51" or "5" as if it was running further
into the file name.

full = ./75px/tn_51eb_expensivepiss.jpg trimmed = tn_51eb_expensivepiss.jpg
full = ./150px/51eb_expensivepiss.jpg trimmed = eb_expensivepiss.jpg
full = ./250px/51eb_expensivepiss.jpg trimmed = 1eb_expensivepiss.jpg

Sorry about the name on that one, it was a humorous picture of a puppy and a
laptop! :-)

It doesn't seem to be obvious why it should be doing this that I can see -
it doesnt seem to have any bearing on string length or anything really
visibly different with the prepended directory name, which is always the
same.

I've altered the code to;
substr_replace($myrow["big_name"],"",0,8);
which seems to work fine in all cases, but I'd still like to get my head
around why the other method failed some of the time.


Regards,

Phil




More information about the Phpwm mailing list