View Single Post
Old 02-20-2013, 06:17 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
How did you get $lat1/$lon1 and $lat2/$lon2 to start with?
In order to get what you want in pairs, you need to specify them as an array within the single offset of $cord.
PHP Code:
$cord = array(
    array(
        
'lat' => array($lat1$lat2),
        
'lon' => array($lon1$lon2),
        
'dotcolor' => array($dotcolor1$dotcolor2)
    )
);

foreach (
$cord AS $itm)
{
    list(
$firstLat$secondLat) = $itm['lat'];
    list(
$firstLon$secondLon) = $itm['lon'];
    list(
$firstDotColour$secondDotColour) = $itm['dotcolor'];
    
printf('$firstLat: %s, $secondLat: %s, $firstLon: %s, $secondLon: %s, $firstDotColour: %s, $secondDotColour: %s',
        
$firstLat$secondLat$firstLon$secondLon$firstDotColour$secondDotColour);

That's for if you want to inter-relate multiple things together.
For individuals at a time, you can use like so:
PHP Code:
$cord[0]['lat'] = $lat1;
$cord[0]['lon'] = $lon1;
$cord[0]['dotcolor'] = $dotcolor1;
$cord[1]['lat'] = $lat2;
$cord[1]['lon'] = $lon2;
$cord[1]['dotcolor'] = $dotcolor2
Or just traditional array building with key=>value pairs. Iteration would then have $value as an array with lat, lon, and dotcolor as valid associative indexes.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote