Hi I was writing a program and my program was as below
$statename =array();
while(! feof($file))
{
$fileData = fgetcsv($file);
//print_r($fileData);
print_r($fileData[9]);
$statename = array_push($statename ,$fileData[9]);
//array_push($a,"blue","yellow");
}
When i try to execute the above code i am getting the following error
Warning: array_push() expects parameter 1 to be array, integer given in
I went into my code and tried to analyse and debug i had to change one thing here and found a solution while(! feof($file))
{
$fileData = fgetcsv($file);
//print_r($fileData); print_r($fileData[9]);
array_push($statename ,$fileData[9]);
//array_push($a,"blue","yellow");
}
i modified the following line
$statename = array_push($statename ,$fileData[9]);
to
array_push($statename ,$fileData[9]);
This is the way i was able to fix my code
Warning: array_push() expects parameter 1 to be array, integer given in and get a solution
Comments
Post a Comment