I am facing a strange problem in array_push function of php.
Lets see my code:
$sets_collection=array();
foreach($result['ques'] as $val){
$sets_collection=array_push($sets_collection,$val['set']);
}
than it gives me the error:
Message: array_push() expects parameter 1 to be array, integer given
But when i do this ,it works fine:
$sets_collection=array();
$i=0;
foreach($result['ques'] as $val)
{
$sets_collection[$i]=$val['set'];
$i++;
}
My question is why this happen,is it necessary that there should be a index of an array than we can perform the push operation?? because in my 1st case the array $set_collection has not an any index and please let me know why this happened??
Try this