phpparsingparse-url

How can i get then "=" Php parse


I need help on php. I get full link with this code

$url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

My link output is: http://localhost/Mid/photo-gallery/photos.php?ref=3%20%20ID=3 How can i get "3" ? I need last number. This number can be 3 digits. So maybe can be 444.


Solution

  • you can do it by using the following code.It will work for you.

      $url = " http://localhost/Mid/photo-gallery/photos.php?ref=3%20%20ID=3 ";
      $urls = explode("ID=",$url);  
      echo $urls[1];