Use this powerful custom feature.
/* $position = false and $sub = false show result of before first occurance of $needle */ /* $position = true and $sub false show result of before last occurance of $needle */ /* $position = false and $sub = true show result of after first occurance of $needle */ /* $position = true and $sub true show result of after last occurance of $needle */ function CustomStrStr($str,$needle,$position = false,$sub = false) { $Isneedle = strpos($str,$needle); if ($Isneedle === false) return false; $needlePos =0; $return; if ( $position === false ) $needlePos = strpos($str,$needle); else $needlePos = strrpos($str,$needle); if ($sub === false) $return = substr($str,0,$needlePos); else $return = substr($str,$needlePos+strlen($needle)); return $return; }
source share