I have a mysql query result which I have turned into an array with:
$row = customfunction_fetch_array($results);
This is how the $row array looks:
Array(
[0]=> Array ([Fruit]=> apple [Count]=>4 [Season]=>Summer
[1]=> Array ([Fruit]=> grape [Count]=>1 [Season]=>Fall
[2]=> Array ([Fruit]=> apple [Count]=>3 [Season]=>Winter
[3]=> Array ([Fruit]=> orange [Count]=>5 [Season]=>Spring
[4]=> Array ([Fruit]=> apple [Count]=>45 [Season]=>All
)
What I'm trying to do is loop through the unique values of a specific field and save them to a new array.
$newArray =[];
foreach( $row["Fruit"] as $myFruits){
$newArray[] = $myFruits;
}
I get a warning of:
"Invalid argument supplied for foreach()"
mysql_fetch_array()doesn't return a multi-dimensional array. How can that be how the$rowarray looks?$row["Fruit"]not being an array. It is a string, so don't useforeachon it.