fork download
  1. <?
  2. $dataString="test='a,b,c=1,d'";
  3. $resultArray=array();
  4. $explodedByComma=explode(',', $dataString);
  5. foreach($explodedByComma as $string){
  6. $string=trim($string);
  7. $explodedByEqual=explode('=', $string);
  8. $key=$explodedByEqual[0];
  9. $value=$explodedByEqual[1];
  10. $resultArray[$key]=$value;
  11. }
  12. var_dump($resultArray);
  13. ?>
Success #stdin #stdout #stderr 0.01s 20568KB
stdin
Standard input is empty
stdout
array(4) {
  ["test"]=>
  string(2) "'a"
  ["b"]=>
  NULL
  ["c"]=>
  string(1) "1"
  ["d'"]=>
  NULL
}
stderr
PHP Notice:  Undefined offset: 1 in /home/F7skGa/prog.php on line 10
PHP Notice:  Undefined offset: 1 in /home/F7skGa/prog.php on line 10