Implode data from a multi-dimensional array

前端 未结 7 861
梦毁少年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:58

    If you want "tag_name" with associated "blogTags_id" use: (PHP > 5.5)

    $blogDatas = array_column($your_multi_dim_array, 'tag_name', 'blogTags_id');
    echo implode(', ', array_map(function ($k, $v) { return "$k: $v"; }, array_keys($blogDatas), array_values($blogDatas)));
    
    0 讨论(0)
提交回复
热议问题