Get URL Parameters

There are multiple methods for getting current URL parameters. The following seem to work fine.

filter_input — Gets a specific external variable by name and optionally filters it . Works on PHP 5 >= 5.2.0.

The following code gets the districts from the url provided in the parameter field_district_ref_nid. The filter input converts the result into an array.

<?php
$districts
= filter_input(INPUT_GET, 'field_district_ref_nid', FILTER_DEFAULT, FILTER_FORCE_ARRAY | FILTER_FORCE_ARRAY);
dpm($districts);
?>

--
Source
http://php.net/manual/en/function.filter-input.php

Technologies: