
Darkwoods
-
Posts
88 -
Joined
-
Last visited
Community Answers
-
Darkwoods's post in How to convert text string into associative array using delimiters? was marked as the answer
Yes this is how I managed to do it but not so sure if it looks good..
but it works
$text = 'cat1=hello,world|cat2=one,two|cat3=value1,value2'; $arr= explode('|', $text); foreach($arr as $value) { $key = rtrim(stristr($value, '=', true), '='); $values = ltrim(stristr($value, '='), '='); $values = explode(',', $values); $array[$key] = $values; } print_r($array);