How to split string with multiple delimiters into array in PHP

1 Answer

0 votes
$words = preg_split("/[\s,-]+/", "php java, python-c++");

print_r($words);



/*
run:

Array
(
    [0] => php
    [1] => java
    [2] => python
    [3] => c++
)

*/

 



answered Oct 15, 2020 by avibootz
...