I am trying to solve a question related to a much bigger script. However the simple example below shows clearly the problem I am attempting to solve in the bigger script. Here is the ready to go code
$a=array("Volvo",22,18);
$b=array("BMW",15,13);
$c=array("Saab",5,2);
$d=array("Land Rover",17,15);
UNSET ($a);
$a=array_filter($a);//remove the null values
$a=array_values($a);//remove the keys
$cars = array
(
$a,
$b,
$c,
$d,
);
print "<pre>";
print_r($cars);
print "</pre>";
My question is as follows...
Unset($a) removes the content of array($a). However as can be seen from the example (print_r) the array($a) is not completely destroyed. The keys remain. That causes a big problem later on as third party validators interpret this residual array data and return a validation error. The only way to get rid of the error is to get rid of the array($a) altogether.
As you can see I have tried array_filter($a) and array_values($a). But the output is unchanged.
Anyone know how to get rid of the array($a) programmatically in this example?
Many thanks
ps Here is the output from Print_r
Array
(
[0] =>
[1] => Array
(
[0] => BMW
[1] => 15
[2] => 13
)
[2] => Array
(
[0] => Saab
[1] => 5
[2] => 2
)
[3] => Array
(
[0] => Land Rover
[1] => 17
[2] => 15
)
)