Notifications
Clear all
Topic starter
//This is my string I want to covert to array
$string = "&type=1&item=140";
$value = array_filter(explode('&', $extra));
foreach ($value as $data) {
$array[] = explode('=', $data);
}
foreach ($array as $value) {
$final[] = array($value[0] => $value[1]);
}
var_dump($final);
Its return this
array (size=2) ----> I want to remove this top level array
0 =>
array (size=1)
'type' => string '1' (length=1)
1 =>
array (size=1)
'item' => string '140' (length=3)
But i want to remove the top level array.. any idea?
Posted : 16/04/2020 9:49 am
that level neither the creator of php cannot remove. that is the variable type
$string = "&type=1&item=140&arr[]=baz";
// Recommended
parse_str($string, $output);
print_r($output['item']);
var_dump($output['item']);
print_r($output['arr']);
var_dump($output['arr']);
var_dump($string);
Posted : 16/04/2020 12:19 pm
Topic starter
Is there any way to merge two arrays to get everything in single array?
Posted : 16/04/2020 1:26 pm