Exploding by Array of Delimiters

前端 未结 5 1920
伪装坚强ぢ
伪装坚强ぢ 2020-12-05 07:56

Is there any way to explode() using an array of delimiters?

PHP Manual:

array explode ( string $delimiter , string $string [, int $limit ] )

<
5条回答
  •  猫巷女王i
    2020-12-05 08:07

    $str = 'Monsters are SUPER scary, bro!';
    $del = array('a', 'b', 'c');
    
    // In one fell swoop...
    $arr = explode( $del[0], str_replace($del, $del[0], $str) );
    

提交回复
热议问题