note 73666 added to function.strrpos
| From: | mijsoot_at_gmail_dot_com at osu1 dot php dot net | Date: | Tue, 06 Mar 2007 09:43:54 +0000 |
| Subject: | note 73666 added to function.strrpos | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124140@lists.php.net to get a copy of this message | ||
To begin, i'm sorry for my English.
So, I needed of one function which gives me the front last position of a character.
Then I said myself that it should be better to make one which gives the "N" last position.
$return_context = "1173120681_0__0_0_Mijsoot_Thierry";
// Here i need to find = "Mijsoot_Thierry"
//echo $return_context."<br />";// -- DEBUG
function findPos($haystack,$needle,$position){
$pos = strrpos($haystack, $needle);
if($position>1){
$position --;
$haystack = substr($haystack, 0, $pos);
$pos = findPos($haystack,$needle,$position);
}else{
// echo $haystack."<br />"; // -- DEBUG
return $pos;
}
return $pos;
}
var_dump(findPos($return_context,"_",2)); // -- TEST
----
Server IP: 195.221.21.36
Probable Submitter: 82.245.30.213
----
Manual Page -- http://www.php.net/manual/en/function.strrpos.php
Edit -- https://master.php.net/note/edit/73666
Del: integrated -- https://master.php.net/note/delete/73666/integrated
Del: useless -- https://master.php.net/note/delete/73666/useless
Del: bad code -- https://master.php.net/note/delete/73666/bad+code
Del: spam -- https://master.php.net/note/delete/73666/spam
Del: non-english -- https://master.php.net/note/delete/73666/non-english
Del: in docs -- https://master.php.net/note/delete/73666/in+docs
Del: other reasons-- https://master.php.net/note/delete/73666
Reject -- https://master.php.net/note/reject/73666
Search -- https://master.php.net/manage/user-notes.php