我被困在這方面,我有多個關聯數組,我想在轉換爲一個: - 這裏是數組: -如何關聯數組轉換到一個數組
Array
(
[0] => Array
(
[0] => Women
)
[1] => Array
(
[0] => children
[1] => smile
)
[2] => Array
(
[0] => Abstract
)
[3] => Array
(
[0] => Lion
[1] => Cheetah
)
)
我想輸出的東西像這樣: -
Array
(
[0] => Women
[1] => children
[2] => smile
[3] => Abstract
[4] => Lion
[5] => Cheetah
)
這裏到目前爲止,我曾嘗試: -
$getKeywords = DB::table('contributor_images')->select('keywords')->get();
$getKeywords = json_decode(json_encode($getKeywords),true);
foreach($getKeywords as $keyword){
$AllKeywords[] = $keyword['keywords'];
}
foreach ($AllKeywords as $key => $ExplodeKeywords) {
$searchkeywords[] = explode(',',$ExplodeKeywords);
}
echo "<pre>"; print_r($searchkeywords); die;
我使用laravel框架的PHP。在此先感謝:)
嘗試[array_flatten](https://laravel.com/docs/5.4/helpers #method-array-flatten) –
嘿@JoeBlack謝謝 –
發表回答我會接受它 –