AleMal
AleMal

Reputation: 2087

PHP extract just a specific number from a string

How is possible extract only the number after the last = symbol in a string like this:

/neuroscan/analysis/admin/listo_aoi_list.php?mastertable=listo_pages&masterkey1=11

the number could be 1,11,345,888888 etc, I would if possible get it into an int variable.

Thanks

Upvotes: 0

Views: 86

Answers (2)

Arpita
Arpita

Reputation: 1398

Try

$url = $_SERVER['REQUEST_URI']; $val = (explode("=",$url)); end($val);

It will always return you the last value after "="

Upvotes: 1

Gaurang Joshi
Gaurang Joshi

Reputation: 695

You can try this:

$url = $_SERVER['REQUEST_URI'];
$val = (explode("=",$url));
echo $val[1];

$val[1] to getting second value after explode text after "="

Upvotes: 1

Related Questions