When I run :
while($r = mysql_fetch_assoc($result3)) {
echo json_encode($r);
}
the results is :
{"test1":"1","test2":"2","test3":"3","test4":"4"}
{"test1":"5","test2":"5","test3":"7","test4":"8"}
my question is :
How can I create arrays from the results above knowing that the number of lines is not fixed, it may change depend on the data. So, I could make changes to the arrays and parse it in a format similar to this :
["test1"=>"1","5"],
["test2"=>"2","6"],
["test3"=>"3","7"],
["test4"=>"4", "8"]
Thanks!!
Try this :
And to encode as JSON (after re-arranging the array) :