Convert JSON string to PHP Array

后端 未结 9 1151
渐次进展
渐次进展 2020-12-16 03:43

I have the following JSON string, which was an Objective C array then encoded to JSON:

 $jsonString=[\\\"a@gmail.com\\\",\\\"b@gmail.com\\\",\\\"c@gmail.com\         


        
9条回答
  •  南方客
    南方客 (楼主)
    2020-12-16 04:34

    You should quote your string, it works fine, see here.

    $jsonString = '["m@gmail.com","b@gmail.com","c@gmail.com"]';
    $arrayOfEmails=json_decode($jsonString);
    

    Or

    $jsonString = "[\"a@gmail.com\",\"b@gmail.com\",\"c@gmail.com\"]";
    $arrayOfEmails=json_decode($jsonString);
    

提交回复
热议问题