从一个字符串创建一个数组,该字符串具有多个特定字符串PHP

I have string1 variable:

$string1 = category=123&code=456&type=type111&type=type222

How to create an array from a string that has a multiple occurances of the string1 variable?

Array(
    array(
        [category] => 123
        [code] => 456
        [type] => type111
    ),
    array(
        [category] => 123
        [code] => 456
        [type] => type222
    )
)

Here is the solution, a bit messy, but works:

<?php
$string = "category=123&code=456&type=type111&type=type222";

$repeated_key = 'type';
$variable = explode('&', $string);
$data_o = array();
foreach ($variable as $key0 => $value0) {
$subvariable = explode('=', $value0);
if($subvariable[0] == $repeated_key){
    continue;
}
$data_o[$subvariable[0]] = $subvariable[1];
}
$i=0;
foreach ($variable as $key1 => $value1) {
$subvariable = explode('=', $value1);
if($subvariable[0] != $repeated_key){
    continue;
}
$data_t = array();
$data_t['type'] = $subvariable[1];
$data[] = array_merge($data_o,$data_t);
$i++;
}
echo "<pre>";
print_r($data);
exit;

?>