note 73714 added to function.strpos
| From: | rcarpenter3 at mn dot rr dot com | Date: | Wed, 07 Mar 2007 18:36:20 +0000 |
| Subject: | note 73714 added to function.strpos | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124201@lists.php.net to get a copy of this message | ||
// 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
----
Server IP: 216.194.113.175
Probable Submitter: 192.55.2.36
----
Manual Page -- http://www.php.net/manual/en/function.strpos.php
Edit -- https://master.php.net/note/edit/73714
Del: integrated -- https://master.php.net/note/delete/73714/integrated
Del: useless -- https://master.php.net/note/delete/73714/useless
Del: bad code -- https://master.php.net/note/delete/73714/bad+code
Del: spam -- https://master.php.net/note/delete/73714/spam
Del: non-english -- https://master.php.net/note/delete/73714/non-english
Del: in docs -- https://master.php.net/note/delete/73714/in+docs
Del: other reasons-- https://master.php.net/note/delete/73714
Reject -- https://master.php.net/note/reject/73714
Search -- https://master.php.net/manage/user-notes.php