可能重复:
How to check if an array element exists?怎么知道的JSON字符串是否存在关键
道歉,如果我错了,我是新来的PHP,有什么办法找出是否密钥存在于使用json_decode
函数进行解码后的Json
字符串中。
$json = {"user_id":"51","password":"abc123fo"};
简介:
$json = {"password":"abc123fo"};
$mydata = json_decode($json,true);
user_id = $mydata['user_id'];
如果JSON字符串不是由USER_ID的,它抛出像Undefined index user_id
一个异常,那么有没有什么办法来检查JSON字符串是否存在的关键,请帮帮我,我正在使用PHP 5.3 and Codeigniter 2.1 MVC
在此先感谢
阅读文档可能会有帮助:http://www.php.net/manual/en/function.array-key-exists.php – 2012-04-16 14:44:56