I have an array in php like this :
$multid_array = array(
"url" => "www.checkmyhouse.cpm",
"date" => "2019/12/12",
"minor" => 1,
"sittingroom" => 1,
"dinningroom" => 2,
"toilet" => 2,
"parking" => 1,
"bedroom" => 2,
"garage" => 2,
"rooms" => 4,
"garden" => 1,
"url_1" => "-sameurl-",
"date_1" => "2019/12/3",
"minor_1" => 3,
"sittingroom_1" => 2,
"dinningroom_1" => 2,
"toilet_1" => 3,
"parking_1" => 1,
"bedroom_1" => 2,
"garage_1" => 6,
"rooms_1" => 6,
"garden_1" => 1,
"url_2" => "-sameurl-",
"date_2" => "2019/12/5",
"minor_2" => 3,
"sittingroom_2" => 2,
"dinningroom_2" => 2,
"toilet_2" => 3,
"parking_2" => 1,
"bedroom_2" => 5,
"garage_2" => 6,
"rooms_2" => 9,
"garden_2" => 1,
);
I have searched around, found this link. but not been able to figure it out. keep getting close. array_slice in multidimensional array?
This is the output I would like:
$array =
[
"levels" => array(
"0" => array(
"url" => "www.checkmyhouse.cpm",
"date" => "2019/12/1",
"minor" => 1,
"sittingroom" => 1,
"dinningroom" => 2,
"toilet" => 2,
"parking" => 1,
"bedroom" => 2,
"garage" => 2,
"rooms" => 5,
"garden" => 1,
),
"1" => array(
"url" => "-sameurl-",
"date" => "2019/12/3",
"minor" => 3,
"sittingroom" => 2,
"dinningroom" => 2,
"toilet" => 3,
"parking" => 1,
"bedroom" => 2,
"garage" => 6,
"rooms" => 6,
"garden" => 1,
),
"2" => array(
"url" => "-sameurl-",
"date" => "2019/12/5",
"minor" => 3,
"sittingroom" => 2,
"dinningroom" => 2,
"toilet" => 3,
"parking" => 1,
"bedroom" => 5,
"garage" => 6,
"rooms" => 9,
"garden" => 1,
)
)
];
Just trying to rearrange it. but I have used array_slice and could only get the output of the first 9 elements.
array_splice($multid_array,9);
But I want to run it automatically, so in case more information gets added into the array then it would still work