我怎麼會去分裂這個陣列通過每個這些視頻訪問和環...拆分此多維數組
array(1) {
[0]=> array(2)
{
[0]=> array(3)
{
["title"]=> string(27) "A test title for this video"
["video_item"]=> string(70) "http://dev.test/wp-content/uploads/2014/01/1.Introduction3.mp4"
["video_image"]=> string(78) "http://dev.test/wp-content/uploads/2014/01/1.Introduction3_thumb23.jpg"
}
[1]=> array(3)
{
["title"]=> string(13) "asdf fads fad"
["video_item"]=> string(67) "http://dev.test/wp-content/uploads/2014/01/Spring-Mower.mp4"
["video_image"]=> string(75) "http://dev.test/wp-content/uploads/2014/01/Spring-Mower1_thumb6.jpg"
}
}
}
這是我使用的,但顯然該代碼不工作
的一部分// this gets the array
$videos = get_post_meta(get_the_ID(), 'video_items', false);
$vid = array();
$img = array();
foreach($videos as $video) {
$vid[] = $video['video_item'];
$img[] = $video['video_image'];
}
你想分割數組的方式是?輸出的例子會很好。 – wallyk
你可以使用'foreach($ videos [0] as $ video)' –
看看我的答案,你在數組中有一個數組,所以你需要訪問原始數組的第一個元素,它是數組您在開始迭代每個數組之前感興趣 – Pavan