Skip to content

Instantly share code, notes, and snippets.

@robotamer
Created April 21, 2011 08:39
Show Gist options
  • Save robotamer/933986 to your computer and use it in GitHub Desktop.
Save robotamer/933986 to your computer and use it in GitHub Desktop.
php rstrstr
<?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, $start=0)
{
return substr($haystack, $start,strpos($haystack, $needle));
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment