3
Guys 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 enter this function into an object array in Javascript?
var array = [{}];
I used the json_encode
as @Shutupmagda suggested, but now my console has the following error:
Syntaxerror: expected Expression, got '>' var contentString = Cord$this->sc_temp_i.local;
I’m using the google maps api, I’m doing it this way:
var cord = [ <?=$this->array_push(retornaGeoCod());?> ];
But the map doesn’t appear :/
I don’t think you know the difference between Client-side and Server-side, I recommend reading : What’s the difference between client-side and server-side code in web development?
– Guilherme Lautert
@gemerich, find out how this data is being received, mention that you are using google maps when asking the question, try to understand at least the functioning of the API and the concept of
arrays
inPHP
and inJavaScript
. Otherwise you’ll be lost...– ShutUpMagda