4
希望我正確地說這個...如何找到鍵是特定值的對象的索引?
我怎麼能找到ID = 68的指數?
我需要幫助創建一個函數,將返回索引2 ...謝謝!
$posts = Array (
[0] => stdClass Object
(
[ID] => 20
[post_author] => 1
[post_content] =>
[post_title] => Carol Anshaw
)
[1] => stdClass Object
(
[ID] => 21
[post_author] => 1
[post_content] =>
[post_title] => Marie Arana
)
[2] => stdClass Object
(
[ID] => 68
[post_author] => 1
[post_content] =>
[post_title] => T.C. Boyle
)
[3] => stdClass Object
(
[ID] => 1395
[post_author] => 1
[post_content] =>
[post_title] => Rosellen Brown
)
)
難道這是'$ index = $ posts [2]'? –