我有一個電影列表,我想比較我從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