I have a function that return a list of cities (and some other data)
//after some logic
print_r($cities);
echo json_encode($cities);
Result of print_r after retreving one city, in this case Medellín city:
Array ( [0] => Array ( [id] => 1 [state_id] => 2 [name] => Medellín [propauthor] => 0 ) )
But the json_encode()
just returns false
EDIT:
json_last_error () returns JSON_ERROR_UTF8
, as you can see cities might have tildes (accents)