简体   繁体   中英

How can i use different string value's in one function?

First i am a beginner in programming in general, i am trying to create a program for using gps locations from Lightroom on a map in googlemaps.

When i use the print the strings below ti the screen i see 5 different value's, this is also what i want, but...

I want to create also 5 different markers on the map this is done by the addMarkerByCoords Function but how can i use the 5 value per strings in the function ?

I have tried array, foreach but i cannot getting to work. The not working part can and probably will be my fault. LOL

 print_r ("$Loncoord");
 print_r ("$Latcoord");
 print_r ("$gui");

//$map->formatOutput = true;

  $map->addMarkerByCoords("$Loncoord","$Latcoord","$gui",'<b>Old Chicago</b>');

Can somebody give me a hint ?

To: Jonathan Sampson: outputs print_r :-5.68166666667, +24.6513888889,IMG_3308,index.html,Landschap

To: Anti Veeranna I removed the " marks (and the program still works), but can you explain why this is better ?

And to the others Thank you very very much for the effort,work and really quick responses.

Assuming that this is PHP, you could us an array of arrays, and then loop.

Something like this:

$items = array(
    array( 
      'long'     => 12.34567,
      'lat'      => 34.56789,
      'gui'      => '????',
      'location' => 'old chicago'
    ),

    ...

    array( 
      'long'     => 12.34567,
      'lat'      => 34.56789,
      'gui'      => '????',
      'location' => 'old chicago 5'
    )
);

foreach ($items as &$item) {
    $map->addMarkerByCoords(
         $item['long'],
         $item['lat'],
         $item['gui'],
         $item['location']
    );
}

unset($item);
$map->addMarkerByCoords(Array($Loncoord, $Latcoord, $gui, '<b>Old Chicago</b>));

??

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM