// Loops through list of players by distance (closest first) for (temp.pl: findnearestplayers(this.x, this.y)) { echo(temp.pl.account); }