How to combine the keys and values of an array in PHP

前端 未结 4 1676
北海茫月
北海茫月 2021-01-17 22:25

Say I have an array of key/value pairs in PHP:

array( \'foo\' => \'bar\', \'baz\' => \'qux\' );

What\'s the simplest way to transform

4条回答
  •  无人及你
    2021-01-17 22:41

    function parameterize_array($array) {
        $out = array();
        foreach($array as $key => $value)
            $out[] = "$key=$value";
        return $out;
    }
    

提交回复
热议问题