DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Strip A String Using Explode

  • submit to reddit

In this example, I need to strip the page's current URL to take off anything that follows a ? in that URL.

$fs_refer= $_SERVER ['REQUEST_URI'];

$fs_refer = explode("?", $fs_refer);
echo "$fs_refer[0] is now a URL without ?.<br />"; 
echo "$fs_refer[1] is the bit that used to follow the ?.";


Snippets Manager replied on Fri, 2006/02/17 - 4:18am

Pull up you command line and type: pear install Net_URL $url = new Net_URL(); print $url->toURL(); print_r($url->querystring); $url->querystring = array(); print $url->toURL(); print_r($url->querystring);