$number_array = array();
//in a while loop
//part of code
if(array_key_exists($read_num, $number_array))
{
$arr[$read_num][A] .= $new_A;
}
else
{
$inner_arr = array( "$read_num" => array( "id"=>$read_num, "A"=>$new_A ) );
$number_array = array_push($number_array,$inner_arr);
unset($inner_arr);
}
I get error like:
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in try.php on line 24
Warning: array_push() [function.array-push]: First argument should be an array in try.php on line 33
I declare an empty array outside of the while loop
$number_array = array();
what did i do wrong here that cause the error to appear
EDIT:
I have this value when I did the code above
Array
(
[0] => Array
(
[0011] => Array
(
[id] => 0011
[A] => 2.50
[B] => 2.00
[C] => 5.40
)
)
[1] => Array
(
[0017] => Array
(
[id] => 0017
[A] => 5.00
[B] => 0.00
[C] => 8.00
)
)
[2] => Array
(
[0022] => Array
(
[id] => 0022
[A] => 1.00
[B] => 0.00
[C] => 1.60
)
)
How do I remove the [0]
, [1]
and [2]
and make it as [0011]
, [0017]
, [0022]
so my array key exists can work