Tuesday, 19 January 2016

Get id or numeric value from URL in PHP

$uri = $_SERVER['REQUEST_URI'];

   function map ($n) {
        $n = preg_replace("%[^\d]+%mi", '', $n);
        return $n;
    }

    $vals = array_map(map, array($uri));
 

foreach($vals as $id)
{
 $id;
}

No comments:

Post a Comment