![]() ![]() arr explode ( del 0, strreplace (del, del 0, str) ) Share Improve this answer Follow edited at 20:19 answered at 20:36 65Fbef05 4,482 1 22 24 That should be faster than regexs, nice one. Use mbstrsplit() to split the string into code points. However, there are other ways in which you achieve the same result: Using strreplace () and explode () Using pregsplit (). strsplit() will split into bytes, rather than characters when dealing with a multi-byte encoded string. For Example example 'Appel Ratte' example2 'apple vs ratte' and I need an array which is explode in or vs. 2 years ago 2 min read By default, the PHP explode () function does not allow specifying multiple delimiters. If you are looking for a simpler multi-explode that returns a flat array, use a regular expression to standardize all delimiters before exploding. The explode() function does not support multiple delimiters, but the string can be converted into an array based on multiple delimiters by using the strreplace. ![]() I have a problem, I have a string array, and I want to explode in different delimiter. ![]() I just wanted to note some behaviours of the explode function, well i am submitting a bunch of urls, one each line and i am using the "\n" (it should be within double quotes) as the delimiter and i am iterating to check for dupe values and always the last value stays unchecked unless i am appending a new line "\n" to the $_POST. phps explode method doesnt support multiple delimiters, so you cant pass it an array. 6 Answers Sorted by: 58 str 'Monsters are SUPER scary, bro' del array ('a', 'b', 'c') // In one fell swoop. 188 This question already has answers here : How to split a string by multiple delimiters in PHP (4 answers) Closed last year. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |