Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to get specific part of a URL

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 455
    Comment on it

    Hi Readers! If you having a useful URL and want to extract the specific part from it you learn the logic below Lets have a example

     $yoururl = "http://www.abc.com/usefulinfo/";
    

    Here I'm getting only the /usefulinfo/ word. For getting this you just need to explode $yoururl

    $usedpart = array_filter(explode("/",parse_url($yoururl,PHP_URL_PATH)));
    

    and now you can echo the useful part of you URL

    echo current($usedpart);//usefulinfo
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: