1

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
1

1 Answer 1

3
<?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
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.