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

前端 未结 4 1660
北海茫月
北海茫月 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:27

    A "curious" way to do it =P

    // using '::' as a temporary separator, could be anything provided
    // it doesn't exist elsewhere in the array
    $test = split( '::', urldecode( http_build_query( $test, '', '::' ) ) );
    

提交回复
热议问题