complex05 Posted January 12, 2007 Share Posted January 12, 2007 Hello,I've built a script but am getting a little confused when it comes to all these arrays.What my code is doing right now is reading images in a directory and grabbing their EXIF data (GPS specifically)[code]<?phpif ($handle = opendir('/home/dtech/public_html/whereisit/maps/')){ while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { //echo $file; $image = exif_read_data("maps/$file",0,true); foreach($image as $key => $section) { foreach($section as $name => $value) { if(is_array($value)) { foreach($value as $axis => $coordinate) { $coordinate = str_replace("/1","",$coordinate); $latitude = array(); if($name == "GPSLatitude") { echo "<li>" . $coordinate; } $longitude = array(); if($name == "GPSLongitude") { echo "<li>" . $coordinate; } } } } } } } closedir($handle);}print_r($longitude);print_r($latitude);?>[/code]Each image has GPSLatitude and GPSLongitude, both are arrays. Each array contains 3 values; they look like thisGPSLongitude[0]: 1GPSLongitude[1]: 2GPSLongitude[2]: 3GPSLatitude[0]: 4GPSLatitude[1]: 5GPSLatitude[2]: 6So each image has 6 gps coordinates in total. I am able, so far, to get all the coordinates, but I cannot group them properly into an array. Basically I want it like this:$image["image1"]["longitude"][0] = 1;$image["image1"]["longitude"][1] = 2;$image["image1"]["longitude"][2] = 3;$image["image1"]["latitude"][0] = 4;$image["image1"]["latitude"][1] = 5;$image["image1"]["latitude"][2] = 6;Any suggestions? I am sort of drawing a blank here.Thanks Link to comment https://forums.phpfreaks.com/topic/33955-exif-arrays/ Share on other sites More sharing options...
complex05 Posted January 12, 2007 Author Share Posted January 12, 2007 *bump* Link to comment https://forums.phpfreaks.com/topic/33955-exif-arrays/#findComment-159465 Share on other sites More sharing options...
complex05 Posted January 12, 2007 Author Share Posted January 12, 2007 well noone replied and i figured it out... if anyone was curious here was my solution:[code]if ($handle = opendir('/home/dtech/public_html/whereisit/maps/')){ while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { //echo $file; $image = exif_read_data("maps/$file",0,true); $images = array(); $images[$file]["lat"][0] = str_replace("/1","",$image['GPS']['GPSLatitude'][0]); $images[$file]["lat"][1] = str_replace("/1","",$image['GPS']['GPSLatitude'][1]); $images[$file]["lat"][2] = str_replace("/1","",$image['GPS']['GPSLatitude'][2]); $images[$file]["log"][0] = str_replace("/1","",$image['GPS']['GPSLongitude'][0]); $images[$file]["log"][1] = str_replace("/1","",$image['GPS']['GPSLongitude'][1]); $images[$file]["log"][2] = str_replace("/1","",$image['GPS']['GPSLongitude'][2]); print_r($images); } }}[/code] Link to comment https://forums.phpfreaks.com/topic/33955-exif-arrays/#findComment-159478 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.