将查询字符串转换为数组

I need help with converting the following query string:

status=SUCCESS&key=9bfad767-abb7-4147-b407-5cec175daa9e&invoice=2712&customer_account=&transaction_id=&fee=&total=70.0&test=true&reference=&process_code=¤cy=&exchange_rate=&reference_number=&message=

Array
(
[status] => SUCCESS
[key] => 9bfad767-abb7-4147-b407-5cec175daa9e
[invoice] => 2712
[customer_account] => 
[transaction_id] => 
[fee] => 
[total] => 70.0
[test] => true
[reference] => 
[process_code] => 
[currency] => 
[exchange_rate] => 
[reference_number] => 
[message] => 
)

you can do following

$str = 'status=SUCCESS&key=9bfad767-abb7-4147-b407-5cec175daa9e&invoice=2712&customer_account=&transaction_id=&fee=&total=70.0&test=true&reference=&process_code=¤cy=&exchange_rate=&reference_number=&message=';

parse_str($str, $output);

print_r($output);
echo $output['status'];
echo $output['key'];
......

Read more

use for loop and explode , code shown below

    <?php
    $string = "status=SUCCESS&key=9bfad767-abb7-4147-b407-5cec175daa9e&invoice=2712&customer_account=&transaction_id=&fee=&total=70.0&test=true&reference=&process_code=¤cy=&exchange_rate=&reference_number=&message=";
    $fullarray = Array();
    $mainarray = explode("&",$string);
    for($i=0;$i<count($mainarray);$i++)
    {
        $tiny = explode("=",$mainarray[$i]);
        $fullarray[$tiny[0]] = $tiny[1];
    }
    print_r($fullarray);

    ?>

enter image description here