note 103577 added to function.strstr
| From: | gruessle at gmail dot com | Date: | Wed, 20 Apr 2011 20:39:51 +0000 |
| Subject: | note 103577 added to function.strstr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-179030@lists.php.net to get a copy of this message | ||
Been using this for years:
<?php
/**
*
* @author : Dennis T Kaplan
*
* @version : 1.0
* Date : June 17, 2007
* Function : reverse strstr()
* Purpose : Returns part of haystack string from start to the first occurrence of needle
* $haystack = 'this/that/whatever';
* $result = rstrstr($haystack, '/')
* $result == this
*
* @access public
* @param string $haystack, string $needle
* @return string
**/
function rstrstr($haystack,$needle)
{
return substr($haystack, 0,strpos($haystack, $needle));
}
?>
You could change it to:
rstrstr ( string $haystack , mixed $needle [, int $start] )
<?php
function rstrstr($haystack,$needle, $start=0)
{
return substr($haystack, $start,strpos($haystack, $needle));
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 70.183.95.165
----
Manual Page -- http://www.php.net/manual/en/function.strstr.php
Edit -- https://master.php.net/note/edit/103577
Del: integrated -- https://master.php.net/note/delete/103577/integrated
Del: useless -- https://master.php.net/note/delete/103577/useless
Del: bad code -- https://master.php.net/note/delete/103577/bad+code
Del: spam -- https://master.php.net/note/delete/103577/spam
Del: non-english -- https://master.php.net/note/delete/103577/non-english
Del: in docs -- https://master.php.net/note/delete/103577/in+docs
Del: other reasons-- https://master.php.net/note/delete/103577
Reject -- https://master.php.net/note/reject/103577
Search -- https://master.php.net/manage/user-notes.php