I have x1, z1, x2 and z2 saved for 2 locations, how can i check the distance between the 2 of those locations?
Use $pos1->distance($pos2). Edit: Fix typo (yes I actually managed to get a typo into one word of text)