Implode data from a multi-dimensional array

前端 未结 7 977
梦毁少年i
梦毁少年i 2020-11-22 12:30

I\'m a novice at PHP and I need a quick solution to the following problem but can\'t seem to come up with one:

I have a multi-dimensional array like so



        
7条回答
  •  孤独总比滥情好
    2020-11-22 12:43

    array_map is a call back function, where you can play with the passed array. this should work.

    $str = implode(',', array_map(function($el){ return $el['tag_id']; }, $arr));
    

提交回复
热议问题