SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm still learning this stuff, and I can't figure out how to extract a single value from a URL.

    I have a several polls, each in a seperate pollX directory.. like this:

    http://www.decertifywestech.com/poll...1</b>/poll.php

    Can someone show me how to exract the number from the directory name using PHP?

    Thanks!
    - A simple online WYSIWYG editor for HTML code snippets.
    - Managed Web Hosting - $3.95/month (resellers welcome)
    - Why pay more? $8.95 domains & $9.95 SSL certificates!

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2001
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how bout this

    <?
    $url=parse_url('http://www.decertifywestech.com/polls/poll1/poll.php ');

    $ex=explode("/",$url[path]);
    $val=split("poll",$ex[2]);
    echo $val[1];
    ?>

  3. #3
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or
    $url= 'http://www.decertifywestech.com/polls/poll1/poll.php';
    $data = explode("/", $url);
    print substr($data[count($data) - 2], 4, strlen($data[count($data) - 2]));
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  4. #4
    SitePoint Enthusiast
    Join Date
    Jan 2001
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    actually...do that, its much cooler =)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •