Implode data from a multi-dimensional array

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

    In this situation implode($array,','); will works, becasue you want the values only. In PHP 5.6 working for me.

    If you want to implode the keys and the values in one like :
    blogTags_id: 1
    tag_name: google

    $toImplode=array();
    foreach($array as $key => $value) {
    $toImplode[]= "$key: $value".'
    '; } $imploded=implode('',$toImplode);

    Sorry, I understand wrong, becasue the title "Implode data from a multi-dimensional array". Well, my answer still answer it somehow, may help someone, so will not delete it.

提交回复
热议问题