I want to find variable from this url string:
this is my string :
$var = "http://localhost/trans/site/index#ads=10"
how can i get $ads
from this string ?
Jignesh Joisar
15.4k6 gold badges68 silver badges61 bronze badges
asked Dec 29, 2018 at 10:28
-
1php.net/manual/en/function.parse-url.phpjeroen– jeroen2018年12月29日 10:28:45 +00:00Commented Dec 29, 2018 at 10:28
1 Answer 1
<?php
$var = "http://localhost/trans/site/index#ads=10";
echo $ads = parse_url($var, PHP_URL_FRAGMENT);
?>
outputs: ads=10
<?php
$var = "http://localhost/trans/site/index#ads=10";
$ads = parse_url($var, PHP_URL_FRAGMENT);
echo $ten = (explode("=",$ads)[1]);
?>
outputs: 10
answered Dec 29, 2018 at 10:49
lang-php