How to Parse Query Strings in PHP

       

Here is a quick snippet for parsing query strings in PHP. You can use the parse_url and parse_str methods. parse_str will create a variable for you populated with results.

$url = "http://www.seanbehan.com/path/?param=key";
parse_str(parse_url(trim($url))['query'], $qs); 
echo $qs;
// returns ['param' => 'key']
Tagged w/ #query string #php #urls #snippets

Apps I've Built

PhotoLocationChanger
Easily change the location on your photos and videos
Click here for more info about the app
PhotoDateChanger
Easily change the dates and times on your photos and videos
Click here for more info about the app
VocabReminder
English dictionary with notifications so you won't forget what you're studying!
Click here for more info about the app
VocabQuiz
The app that quizzes and scores you on your vocabulary!
Click here for more info about the app