我查詢WP DB獲得如下:在串行化數組中創建一個數組鍵的數組。
用戶ID COLLECTION_NAME collection_data(連載陣列)
我運行下面的foreach循環:
foreach($result as $row){
$row->collection_name;
$cleandata = unserialize($row->collection_data);
的$ cleandata的print_r的給我以下陣列:
Array
(
[7] => Array
(
[ExerciseID] => 7
[Description] => Description?!
[Sets] => 12
[Reps] => 12
[Load] => 12
[Rest] => 12
[Tempo] => 12
)
)
從這我需要d創建一個ExerciseID數組,以便將它們放入以下WP_query中。
$the_query = new WP_Query(array('post__in' => $ids, 'post_type' => 'exercise','posts_per_page' =>'4000')); ?>
我已經試過不過我越來越漂亮的堅持了下來在foreach $result as $row
內運行的其他的foreach。
非常感謝提前。
什麼是你的PHP版本?在5.5中,很容易調用['array_column($ cleandata,'ExerciseID')'](http://us1.php.net/manual/en/function.array-column.php) –
所以我會做'$ ids = array_column($ cleandata,'ExerciseID');'? – Taylorsuk
是的,_if_你有PHP 5.5+。否則,請在下面使用Mark的答案。 –