I’m having trouble splitting this string into an array in the pattern I need it to be. The string is:
ATTRIBUTE1: +VALUE1;
ATTRIBUTE2: -VALUE2%;
I essentially need an array like this:
array (
[0] => "ATTRIBUTE1",
[1] => "+",
[2] => "VALUE1",
[3] => "%"
)
array (
[0] => "ATTRIBUTE2", ...
)
The “%” is optional, but the +/- sign is not. Any help would be appreciated!
You could use regex:
Prints:
You might have to play around with the regex, but it’s got comments now so it shouldn’t be too hard to figure it out.