SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2009
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    seperate GET variables

    hi,

    I am a little unsure of how to seperate a GET variable into 3 different values.

    for example the url might be demo.php?id=abcd1234demotext1234

    I am hoping to split this into
    Code PHP:
    $alpha = "abcd";
    $numeric = "1234";
    $alphanumberic = "demotext1234";

    The variable will always be in the format of alpha, numeric, alphanumberic...

    Any help would be much appreciated

    Rob

    EDIT: its just occurred to me that this can be done using a mod rewrite?

  2. #2
    SitePoint Zealot RishikeshJha's Avatar
    Join Date
    Mar 2009
    Location
    INDIA
    Posts
    146
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by robert7b View Post
    hi,

    I am a little unsure of how to seperate a GET variable into 3 different values.

    for example the url might be demo.php?id=abcd1234demotext1234

    I am hoping to split this into
    Code PHP:
    $alpha = "abcd";
    $numeric = "1234";
    $alphanumberic = "demotext1234";

    The variable will always be in the format of alpha, numeric, alphanumberic...

    Any help would be much appreciated

    Rob

    EDIT: its just occurred to me that this can be done using a mod rewrite?
    Is the id in url is fixed?

  3. #3
    SitePoint Zealot jimmy85's Avatar
    Join Date
    Aug 2009
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can't you make it like this

    demo.php?x=abcd&y=1234&z=demotext1234

    and just concatenate the strings on the receiving script?

  4. #4
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $id "abcd1234demotext1234";
    $pattern "/([a-z]+)([0-9]+)([a-z0-9]+)/i";

    preg_match($pattern$id$matches);
    var_dump($matches); 


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
  •