class - PHP Function producing two iterations of an array, in the same array -


i've got function gets data nosql database, , if it's not available goes mysql database data issue is, function putting data array twice , can't figure out why.

expected result

array(2) {  ["id"]=> string(2) "30"  ["username"]=> string(8) "username" } 

actual result

array(4) {  [0]=> string(2) "30"  ["id"]=> string(2) "30"  [1]=> string(8) "username"  ["username"]=> string(8) "username" } 

code

code irrelevant problem removed , replaced pseudo code comments.

        $connection = $this->connect("mysqli");         $data = mysqli_fetch_array(              mysqli_query($connection["mysqli"], $options["query"])          );          echo "got array (mysqli)."; 

it's worth noting string "got array (mysqli)." appears once.

mysqli_fetch_array() takes parameter, resulttype, default set mysqli_both.

by using mysqli_assoc constant function behave identically mysqli_fetch_assoc(), while mysqli_num behave identically mysqli_fetch_row() function. the final option mysqli_both create single array attributes of both.

mysqli_fetch_assoc fetches associative array, while mysqli_fetch_row fetches array numeric indexes.

mysqli_fetch_array parameter mysqli_both fetch both named (associative) indexes , numeric indexes in same array.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -