Results 1 to 3 of 3

Thread: php separate string

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2013
    Posts
    1,126

    php separate string

    I want to separate the string URL

    The whole URL string is

    http://www.website1.com/select.php?v...lue2=HIJKLMNOP

    I want to get the values below.

    string 1 = http://www.website1.com/select.php?value1=ABCDEFG
    string 2 = HIJKLMNOP

    I dont know much about php string manipulation. Please kindly help for me to learn as well. Thanks so much.

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: php separate string

    This will get you the current URL: http://webcheatsheet.com/php/get_current_page_url.php
    and this can parse out the querystring parameters: http://php.net/manual/en/function.parse-url.php

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: php separate string

    Assuming a user is supplying that string via a form, and its the same exact format every time, then you can just explode the string.

    http://www.website1.com/select.php?v...lue2=HIJKLMNOP

    PHP Code:

    $string 
    "http://www.website1.com/select.php?value1=ABCDEFG&value2=HIJKLMNOP";
    $array explode('&value2='$string);

    echo 
    $array[0]; //http://www.website1.com/select.php?value1=ABCDEFG
    echo $array[1]; //HIJKLMNOP 
    My usual boring signature: Something

Posting Permissions

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



Click Here to Expand Forum to Full Width