Php multiple delimiters in explode [duplicate]
Try about using: $output = preg_split(‘/ (@|vs) /’, $input);
Try about using: $output = preg_split(‘/ (@|vs) /’, $input);
You can achieve this by following code, $integerIDs = array_map(‘intval’, explode(‘,’, $string));
You could use a preg_match_all(…): $text=”Lorem ipsum “dolor sit amet” consectetur “adipiscing \\”elit” dolor”; preg_match_all(“https://stackoverflow.com/”(?:\\\\.|[^\\\\”])*”|\S+/’, $text, $matches); print_r($matches); which will produce: Array ( [0] => Array ( [0] => Lorem [1] => ipsum [2] => “dolor sit amet” [3] => consectetur [4] => “adipiscing \”elit” [5] => dolor ) ) And as you can see, … Read more
Using a simple regex via preg_match_all and array_combine is often the shortest and quickest option: preg_match_all(“/([^\\\\]+)\\\\([^\\\\]+)/”, $string, $p); $array = array_combine($p[1], $p[2]); Now this is of course a special case. Both keys and values are separated by a \ backslash, as are all pairs of them. The regex is also a bit lengthier due to … Read more
Try explode: $myString = “9,admin@example.com,8”; $myArray = explode(‘,’, $myString); print_r($myArray); Output : Array ( [0] => 9 [1] => admin@example.com [2] => 8 )