I have a string where there are arrays separated by {|} like this :
$string = "Hi, {Mr.|Mrs.} {Alvin|Dale}! Good Morning!";
One of the many things I've tried :
$string = "Hi, {Mr.|Mrs.} {Alvin|Dale}! Good Morning!";
preg_match_all("/[()=]|\\{[^\}]+\\}|[+-]|[^=]+$/", $string, $matches);
Expected result:
$result = array (
0 => array ( 0 => 'Hi, '),
1 => array ( 0 => 'Mr.', 1 => 'Mrs.'),
2 => array ( 0 => ' '),
3 => array ( 0 => 'Alvin', 1 => 'Dale'),
4 => array ( 0 => '! Good Morning!')
);
Actual result:
$result = array (
0 => 'Hi, {Mr.|Mrs.} {Alvin|Dale}! Good Morning!'
);