I have a function, and it returns an array.
class myarray
{
public function getAr()
{
// mysql query
while($dd= $database->fetch(PDO::FETCH_ASSOC))
{
$data[] = $dd; //there's values in the array
}
return $data;
}
public function get3()
{
// mysl query
while($dd= $database->fetch(PDO::FETCH_ASSOC))
{
$data[] = $dd; //there's values in the array
}
return $data;
}
}
How come I tried to merge together the array:
$get = new myarray();
$arrayAr = $get->getAr();
$array3 = $get->get3();
$new_array = array_merge($arrayAr ,$array3);
It says that its not an array?
array_merge() [function.array-merge]: Argument #1 is not an array
But I can print_r($arrayAr);
and its like an array?
Help?
Thanks
array
- that could cause some confusion... Is this the code you are using or some pseudo code to simplify the problem? – Lix Sep 3 '12 at 5:35$d
gets out of nowhere too. – Shikiryu Sep 3 '12 at 5:36class array
should give you aPHP Parse error
. But besides that your code returns an array containing NULL two times. Which is to be expected since$d
, like @Shikiryu stated, comes out of nothing. – Michael Sep 3 '12 at 5:40