search

Home  >  Q&A  >  body text

PHP array transformation expert enters

array(3) { [0]=> array(1) { ["id"]=> int(852) } [1]=> array(1) { ["id"]=> int(853) } [2]=> array(1) { ["id"]=> int(854) } }

How to add an id of 845 to such an array and then turn the array
into a string of 852,853,854, 845?

淡淡烟草味淡淡烟草味2750 days ago654

reply all(4)I'll reply

  • 習慣沉默

    習慣沉默2017-05-24 11:35:51

     $arr=[['id'=>852],['id'=>853],['id'=>854]];
        foreach ($arr as $key => $value) {
        $new[]=implode('',$value);
        }
        $new[]='845';
        $new=implode(',',$new);
        var_dump($new);

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-24 11:35:51

    $ARR [] = ['id'=>845];
    The subsequent transformation was answered downstairs

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-24 11:35:51

    $arr = array(
        array('id' => 852),
        array('id' => 853),
        array('id' => 854),
    );
    $arr[] = array('id' => 845);
    $arr = array_column($arr, 'id');
    $str = implode(',', $arr);
    var_dump($str);

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-24 11:35:51

    The same error message is reported when you run it alone

    reply
    0
  • Cancelreply