我有一个电影列表,我想比较我从Facebook Graph API获得的电影阵列。如何将列表中的名称与数组中的名称进行比较?
这里是API越来越的例子:
{"data": [
{
"name": "The Drift Bible",
"category": "Movie",
"id": "227431881228",
"created_time": "2011-02-27T21:41:04+0000"
},
{
"name": "Shooter",
"category": "Movie",
"id": "109671005718938",
"created_time": "2011-02-16T09:18:29+0000"
}...
我需要比较列表是相当大的,但这里有一些:
Wall Street, Shooter, Young Guns, Due Date...
基本上只是在比较“名称” '数据'与'我的名单'的电影标题。但想不通的语法
喜欢的东西:
if ($movies->data->name == 'movie titles list') {echo "You like the same movies";}
我发现这一点:
if (in_array('movie titles list', $a)) {echo "You like the same movies";}
任何想法会帮助我。
感谢
以及如果我做的var_dump我得到:对象(stdClass的)#2(1){ [“data”] => array(18){[0] => object(stdClass)#3(4){[“name”] => string(15)“The Drift Bible”[“category”] =>字符串(5)“电影”[“id”] =>字符串(12)“227431881228” [“created_time”] => string(24)“2011-02-27T21:41:04 + 0000”} [1] => object(stdClass)#4(4){[“name”] => string(7 )“射手”[“category”] => string(5)“Movie”[“id”] => string(15)“109671005718938”[“created_time”] => string(24)“2011-02-16T09: 18:29 + 0000“} – TheRealDK 2011-03-28 20:14:10
可能想检查您的变量并关闭大括号。 – drudge 2011-03-28 20:15:57
sry刚刚关闭她在示例中发布的数据,应该修复 – 2011-03-28 20:16:50