I am getting strange behaviour from this function.
Input
public function fetch_array($result_set)
{
$rows = array();
while ($row = mysql_fetch_array($result_set))
{
$rows[] = $row;
print_r($row);
break;
}
return $rows;
}
I have made the function run once but it its duplicating a row from my MySQL query result.
Output
Array ( [0] => Sarah [first_name] => Sarah [1] => Palin [second_name] => Palin )
It should be
Correct Output
Array ( [first_name] => Sarah [second_name] => Palin )
I used this SO question example
Use mysql_fetch_array() with foreach() instead of while()
Not my query or Mysql result fault
https://i.stack.imgur.com/icUYI.png

What is going wrong here?
This is not an error, it’s the intended behavior of
mysql_fetch_array()http://us.php.net/manual/en/function.mysql-fetch-array.phpYou can either set the
result_typeflag, or you can just usemysql_fetch_assoc()instead. http://us.php.net/manual/en/function.mysql-fetch-assoc.php