Is there any way to explode() using an array of delimiters?
PHP Manual:
array explode ( string $delimiter , string $string [, int $limit ] )
Instead of using string $delimiter
is there any way to use array $delimiter
without affecting performance too much?
The explode() function breaks a string into an array. Note: The "separator" parameter cannot be an empty string. Note: This function is binary-safe.
explode() is a built in function in PHP used to split a string in different strings. The explode() function splits a string based on a string delimiter, i.e. it splits the string wherever the delimiter character occurs. This functions returns an array containing the strings formed by splitting the original string.
The explode function is utilized to "Split a string into pieces of elements to form an array". The explode function in PHP enables us to break a string into smaller content with a break. This break is known as the delimiter.
$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) );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With