Ouzo\Utilities\Strings::removePrefix PHP Method

removePrefix() public static method

Example: $string = 'prefixRest'; $withoutPrefix = Strings::removePrefix($string, 'prefix'); Result: Rest
public static removePrefix ( string $string, string $prefix ) : string
$string string
$prefix string
return string
    public static function removePrefix($string, $prefix)
    {
        if (self::startsWith($string, $prefix)) {
            return substr($string, mb_strlen($prefix));
        }
        return $string;
    }

Usage Example

Beispiel #1
0
 /**
  * @test
  */
 public function shouldRemovePrefixWhenStringIsEqualToPrefix()
 {
     //given
     $string = 'prefix';
     //when
     $withoutPrefix = Strings::removePrefix($string, 'prefix');
     //then
     $this->assertEquals('', $withoutPrefix);
 }
All Usage Examples Of Ouzo\Utilities\Strings::removePrefix