note 54442 deleted from function.basename by nlopess
| From: | nlopess@php.net | Date: | Mon, 04 Jul 2005 20:14:32 +0000 |
| Subject: | note 54442 deleted from function.basename by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-91436@lists.php.net to get a copy of this message | ||
Note Submitter: Dan Langille
----
If you find that basename is corrupting the original string, you're seeing this bug: http://bugs.php.net/bug.php?id=15234
To get around it, take a copy of the string and use that in your call to basename.
For example:
<?php
$a=array("x.y");
foreach($a as $b)
{
$tmp = $b .'';
$c=basename($tmp,".y");
print "\$c is '$c'<br>\n";
print $a[0] . "<br>\n";
print $tmp . "<br>\n";
}
?>
Gives this:
$c is 'x'
x.y
x
Note that $tmp has been corrupted. If you didn't do that assignment with the string
concatenation, $b would have been corrupted too. As well as $a[0].