我在$ result中有$result = json_encode($json)
的JSON输出。我如何才能访问Mickey,Maddu,mickey @ gmail等值。我需要将这些值存储在变量中。
JSON输出
{"jsonFirstName":"Mickey","jsonLastName":"Maddu","jsonEmail":"[email protected]","jsonPassword":"QWERqwer!@#$","jsonDob":"2014-01-01","jsonDobTime":"dobtime","jsonLocaldob":"2014-01-01T01:00","jsonSsn":"123-12-1234","jsonPhonenumber":"123-123-1234","jsonCreditcardnumber":"123412341234"}
最佳答案
您只需要使用extract()
。 (提供数组保持一维)
$json = '{"jsonFirstName":"Mickey","jsonLastName":"Maddu","jsonEmail":"[email protected]","jsonPassword":"QWERqwer!@#$","jsonDob":"2014-01-01","jsonDobTime":"dobtime","jsonLocaldob":"2014-01-01T01:00","jsonSsn":"123-12-1234","jsonPhonenumber":"123-123-1234","jsonCreditcardnumber":"123412341234"}';
extract(json_decode($json, true));
echo $jsonLastName;
Example
关于php - PHP-如何在$ firstName,$ lastName等变量中访问和存储JSON值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26248452/