I want to parse a string into three variables. My formatted input string starts with [|
, the 3 sought values are delimited by ||
, and the string ends with |]
.
Intention:
'[|'.$1.'||'.$2.'||'.$3.'|]'
What I have tried doesn't produce the desired results:
preg_match_all("[|(.*)||(.*)||(.*)|]", $loadedList, $result);
What about this? It will work for a variable amout of items.
$result = explode('||', preg_replace('/(^\[\||\|\]$)/', '', $loadedList));