How to use the explode function in PHP using 2 delimeters instead of 1? -


suppose have following:

$string = "(a) (b) (c)"; 

how explode contents inside parenthesis. if string's contents separated 1 symbol instead of 2 have used:

$string = "a-b-c"; explode("-", $string); 

but how when 2 delimiters used encapsulate items exploded?

you have use preg_split or preg_match instead.

example:

$string = "(a) (b) (c)"; print_r(preg_split('/\\) \\(|\\(|\\)/', $string, -1, preg_split_no_empty)); 
 array (     [0] =>     [1] => b     [2] => c ) 

notice order important.


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -