I have this php function returning this String:
function retornaGeoCod(){
for($i = 0; $i < 2; $i++){
echo '{
"lat":"-19.4746845",
"long":"-44.159503",
"local":"Prudente de Morais"},';
}
}
How do I insert this function into an array of JavaScript objects?
var array = [{}];
I used json_encode
as @ShutUpMagda suggested, but now my console has the following error:
SyntaxError: expected expression, got '>' var contentString = string $ this- > sc_temp_i.local;
I'm using google maps api, I'm doing it this way:
var cord = [ <?=$this->array_push(retornaGeoCod());?> ];
But the map does not appear: /