Ouzo\Utilities\Strings::substringAfter PHP Method

substringAfter() public static method

Gets the substring after the first occurrence of a separator. The separator is not returned.
public static substringAfter ( string $string, string $separator ) : string
$string string
$separator string
return string
    public static function substringAfter($string, $separator)
    {
        $pos = mb_strpos($string, $separator);
        if ($pos === false) {
            return $string;
        }
        return mb_substr($string, $pos + 1, mb_strlen($string));
    }

Usage Example

Beispiel #1
0
 /**
  * @test
  */
 public function shouldReturnStringInSubstringAfterSeparatorWhenSeparatorIsNotFound()
 {
     //given
     $string = 'abc';
     //when
     $result = Strings::substringAfter($string, '-');
     //then
     $this->assertEquals('abc', $result);
 }