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.