note 73714 deleted from function.strpos by nlopess
| From: | nlopess@php.net | Date: | Sun, 11 Mar 2007 12:48:57 +0000 |
| Subject: | note 73714 deleted from function.strpos by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-124331@lists.php.net to get a copy of this message | ||
Note Submitter: rcarpenter3 at mn dot rr dot com
----
// Find the last occurence of a character
$correctPath = "c:\\local\\temp\\dir\\file.abc";
$pos = 0;
$lastPos = 0;
do{
$lastPos = $pos;
$pos = strpos( $correctPath, "\\", $pos + 1 );
echo $pos . "\n";
}
while ( $pos !== FALSE );
echo $correctPath . "\n";
echo "pos of last \\ - " . $lastPos . "\n";
echo substr( $correctPath, 0, $lastPos ) . "\n";
// Output
// c:\local\temp\dir\file.abc
/ pos of last \ - 17
// c:\local\temp\dir