$ne_do_array = "key:val|key2:val2|key3:val3";
$array = [
'key' => 'val',
'key2' => 'val2',
'key3' => 'val3'
];
function parse($str) {
$parsed = [];
foreach (explode("|", $str) as $elem) {
list($key, $val) = explode(":", $elem);
$parsed[$key] = $val;
}
return $parsed;
}
есть ли более простой способ?