prepare($query); $stm->execute(); $row = $stm->fetchAll(PDO::FETCH_ASSOC); $listUser = []; $lat1=0; $lng1=0; Foreach ($row as $col) { if ($col['id']==0){ //1 est lid de l'user qui execute la commande le recup grâce à driko $lat1=$col['latitude']; $lng1=$col['longitude']; }/*if ($lat1==0 && $lng1==0){ print ("ERROR No user found in the database (normally not supposed to happen)"); exit(666); }*/ } Foreach ($row as $col) { if ($col['id']!=1) { //1 est lid de l'user qui execute la commande le recup grâce à driko $lat2 = $col['latitude']; $lng2 = $col['longitude']; $userID = $col['id']; $dist = (new distance)->meters($lat1, $lng1, $lat2, $lng2); if ($dist <= 100) { $listUser[] = $userID; } } } return $listUser; } } echo implode(",",(new ListUser)->ListOfUser());