Almost similar questions are repeated.
I am updating and fetching string from database for different issues.
lets say after fetching value from database one of my variable $str
looks like one of the below
$str = "1:1,2:1,3:2,5:6";
or
$str = "1|1,2|1,3|2,5|6";
or
$str = "1=1,2=1,3=2,5=6";
how can I convert anyone or almost different string to an associative array in PHP
thanks in advance. I tried for an answer but didnt find anything similar.
code i tried to make it an associative array
$firstArr = explode(',', $str);
foreach (firstArr as $value) {
$secondArr = explode(':', $value);
}