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.sstatic.net/icUYI.png

What is going wrong here?
$rowsarray is exactly the same as the$rowarray returned frommysql_fetch_array. So why not just return$rowafter you fetched it? On a side note: don't use themysql_functions. They will soon be removed from PHP. And usemysql_fetch_associnstead ofmysql_fetch_array.