這裏是一個數組,我想提取「category_input」作爲子數組。這個子數組包含「cat_id」和「post-titles」。然後,我想將帖子插入到每個類別下的WordPress DB中。是。 cat_20將有帖子命名爲post-in-cat-20等等。php從數組中獲取子數組
Array
(
[post_type] => post
[post_status] => publish
[content_texarea] =>
[category_input] => Array
(
[0] => cat_20
[1] => post-in-cat-20
[2] => post-in-cat-20
[3] => post-in-cat-20
[4] => cat_19
[5] => post-in-cat-19
[6] => post-in-cat-19
[7] => post-in-cat-19
[8] => post-in-cat-19
[9] => cat_2
[10] => post-in-cat-2
[11] => post-in-cat-2
[12] => post-in-cat-2
)
)
預期結果
提取陣列將作爲
[category_input] => Array
(
[0] => cat_20
[1] => post-in-cat-20
[2] => post-in-cat-20
[3] => post-in-cat-20
[4] => cat_19
[5] => post-in-cat-19
[6] => post-in-cat-19
[7] => post-in-cat-19
[8] => post-in-cat-19
[9] => cat_2
[10] => post-in-cat-2
[11] => post-in-cat-2
[12] => post-in-cat-2
)
然後,我將需要caegory和崗位陣列中的WP查詢
[category_input] => Array
(
[cat_20] => Array
[1] => post-in-cat-20
[2] => post-in-cat-20
[3] => post-in-cat-20
[cat_19] => Array
[5] => post-in-cat-19
[6] => post-in-cat-19
[7] => post-in-cat-19
[8] => post-in-cat-19
[cat_2] => Array
[10] => post-in-cat-2
[11] => post-in-cat-2
[12] => post-in-cat-2
)
請加上預期結果 –
哪一個是你的願望輸出?第二個?? –
是第二個結果 –