Ouzo\Utilities\Strings::removePrefixes PHP Method

removePrefixes() public static method

Example: $string = 'prefixRest'; $withoutPrefix = Strings::removePrefixes($string, array('pre', 'fix')); Result: Rest
public static removePrefixes ( string $string, array $prefixes ) : mixed
$string string
$prefixes array
return mixed
    public static function removePrefixes($string, array $prefixes)
    {
        return array_reduce($prefixes, function ($string, $prefix) {
            return Strings::removePrefix($string, $prefix);
        }, $string);
    }

Usage Example

コード例 #1
0
ファイル: StringsTest.php プロジェクト: letsdrink/ouzo
 /**
  * @test
  */
 public function shouldRemovePrefixes()
 {
     //given
     $string = 'prefixRest';
     //when
     $withoutPrefix = Strings::removePrefixes($string, array('pre', 'fix'));
     //then
     $this->assertEquals('Rest', $withoutPrefix);
 }