Robert Kent

Personal blog of Robert Kent

PHP: Distance between two points

This snippet uses the latitude and longitude of two locations and calculates the distance between them. Results are given in both miles and metric units.

Example usage:


Drupal 7: Inserting text with the Form API

It can be helpful to insert content into form markup such as help text for users. Here’s how you can do this even if you didn’t build the form markup using hook_form_alter. In your template.php add the following: