Imploding an associative array in PHP

后端 未结 7 790
攒了一身酷
攒了一身酷 2020-12-08 19:44

Say I have an array:

$array = Array(
  \'foo\' => 5,
  \'bar\' => 12,
  \'baz\' => 8
);

And I\'d like to print a line of text in m

7条回答
  •  情话喂你
    2020-12-08 20:16

    For me the best and simplest solution is this:

    $string = http_build_query($array, '', ',');
    

    http_build_query (php.net)

提交回复
热议问题