I have an array populated using an sql statement in the following manner:
$index = 0;
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC))
{
$bookname[$index] = ($row['Bookname']);
$subjectname[$index] = ($row['SubjectName']);
$index++;
}
When I go to echo json encode the Arrays I get a blank [] when I know it has been populated which is really weird. Am I doing anything wrong in my context
echo json_encode($Bookname,$SubjectName);
json_encode()sets options on how to encode the data. Do not use some of your data in that place or you'll ge t really weired results. See php.net/manual/en/function.json-encode.phpvar_dump(json_encode($Bookname));orvar_dump(json_encode($SubjectName));you can not print anobjectorarrayusingecho