Jump to content

how can i unset this array value?


vlowe

Recommended Posts

hi

 

i have an array that returns the longitude, latitude and timestamp of multiple users.

 

then i use a for each loop to echo the details to add markers to google maps.

 

the problem is that if one of the users has no gps position i dont want to include it it my foreach loop.

 

foreach($positions as $name => $status) {
echo 'add(jQuery(this), number += 1, "' . $name . '", "map_post.php?n=' . $name . '&u=' . $status['user_id']. '", "' . date("d-m-Y @ h:i:s",$status['timestamp']) . '", "' . $status['latitude'] . '", "' . $status['longitude'] . '", "' . $status['user_id']. '");';
}

 

how can i get the foreach to ignore the users with no data?

Link to comment
https://forums.phpfreaks.com/topic/249626-how-can-i-unset-this-array-value/
Share on other sites

how can i get the foreach to ignore the users with no data?

 

No offense, but if you can't answer that question you should consider looking for another job.

 

if ($status['latitude'] && $status['longitude']) {

 

Will skip the users with no valid latitude & longitude although you probably should put this in your query.

 

WHERE latitude > 0 && longitude > 0

 

Which negates the need for an if statement in your foreach.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.