2d multidimensional array to 1d array in php

后端 未结 8 1813
陌清茗
陌清茗 2021-01-06 00:51

Just wondering if anyone has transformed a 2 dim array to a one dim array in php. I\'ve yet to come across a clear explanation in php. Any suggestion would be appreciated.

8条回答
  •  一个人的身影
    2021-01-06 01:23

    This might be helpful to you if you fetching values from Query here you can use array function which will support in PHP 5.5+

    $myfield_arr = array_column($query_result, 'myfield_name');
    

    Say Good bye to loop! Enjoy Smart Code.

提交回复
热议问题