I'm trying to write a regex in php to split the string to array. The string is
#000000 | Black #ffffff | White #ff0000 | Red
there can or cannot be space between the character and
|
so the regex needs to work with
#000000|Black #ffffff|White #ff0000|Red
For the second type of string this works.
$str = preg_split('/[\s]+/', $str);
How can I modify it to work with the first and second both strings?
Edit: Final output needs to be
Array ( [0] => Array ( [0] => #000000 [1] => Black ) [1] => Array ( [0] => #ffffff [1] => White ) [2] => Array ( [0] => #ff0000 [1] => Red) )