Seriously. Stop it. Or you’ll end up with garbage like this, in which a developer
writes two separate functions for converting JSON to
an array, only one of which is compatible with json_decode.
Yes, both are in production.
<?phpfunctionjsonToArray($jsonData){$newArray=array();// remove first and last []$length=strlen($jsonData)-2;$jsonString=substr($jsonData,1,$length);if($jsonString!=""){// tokenize, using , as a divider$newArray=explode(",",$jsonString);}return$newArray;}// Converts JSON data string to PHP array// Assumes this format: ["Some text","Even more text"]functionjsonStringsToArray($jsonData){// remove first and last []$length=strlen($jsonData)-2;$jsonString=substr($jsonData,1,$length);// tokenize, using , as a divider$newArray=explode(",",$jsonString);$lastArray=array();for($i=0;$i<sizeof($newArray);$i++){$thisLength=strlen($newArray[$i])-2;$lastArray[]=substr($newArray[$i],1,$thisLength);}return$lastArray;}