In my php I am reading a file and successfully getting each row into an array ($line[1]
because its a 3 column CSV and I just need the 2nd value):
while (($line = fgetcsv($file, 1000)) !== false)
{
$course[] = array('course' => $line[1]);
}
$course[]
correctly contains the array like:
0 =>
array (size=1)
'course' => string 'Course One' (length=68)
1 =>
array (size=1)
'course' => string 'Course Two' (length=45)
Problem is I cannot get the array to convert to json using json_encode
$json_res = json_encode($course);
EDIT: So just to be clear, I have array like this
2 =>
array (size=1)
'course' => string 'Associate Degree of Business Studies' (length=36)
3 =>
array (size=1)
'course' => string 'Associate Degree of Business Administration' (length=43)
$json_encode
, gives me
boolean false