3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $string = "http://www.google.co.in/#hl=en&gs_rn=12&gs_ri=psy-ab&pq=bus%20online%20booking&cp=8&gs_id=20&xhr=t&q=redbus+offer+code&es_nrs=true&pf=p&sclient=psy-ab&oq=redbus+o&gs_l=&pbx=1&bav=on.2,or.r_qf.&bvm=bv.45960087,d.bmk&fp=e8cb228a72cb543b&biw=1280&bih=685"; $string = "http://www.google.co.in/#hl=en&gs_rn=12&gs_ri=psy-ab&pq=bus%20online%20booking&cp=8&gs_id=20&xhr=t&q=redbus+offer+code&es_nrs=true&pf=p&sclient=psy-ab&oq=redbus+o&gs_l=&pbx=1&bav=on.2,or.r_qf.&bvm=bv.45960087,d.bmk&fp=e8cb228a72cb543b&biw=1280&bih=685"; $query = parse_url($string, PHP_URL_FRAGMENT); parse_str($query, $query_array); var_dump($query_array); $regex = "/q=(.*?)&/"; preg_match($regex, $string, $matches); var_dump($matches);
Output for 5.1.2 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(19) { ["hl"]=> string(2) "en" ["gs_rn"]=> string(2) "12" ["gs_ri"]=> string(6) "psy-ab" ["pq"]=> string(18) "bus online booking" ["cp"]=> string(1) "8" ["gs_id"]=> string(2) "20" ["xhr"]=> string(1) "t" ["q"]=> string(17) "redbus offer code" ["es_nrs"]=> string(4) "true" ["pf"]=> string(1) "p" ["sclient"]=> string(6) "psy-ab" ["oq"]=> string(8) "redbus o" ["gs_l"]=> string(0) "" ["pbx"]=> string(1) "1" ["bav"]=> string(13) "on.2,or.r_qf." ["bvm"]=> string(17) "bv.45960087,d.bmk" ["fp"]=> string(16) "e8cb228a72cb543b" ["biw"]=> string(4) "1280" ["bih"]=> string(3) "685" } array(2) { [0]=> string(25) "q=bus%20online%20booking&" [1]=> string(22) "bus%20online%20booking" }
Output for 4.3.0 - 5.1.1
<br /> <b>Warning</b>: parse_url() expects exactly 1 parameter, 2 given in <b>/in/MmBGk</b> on line <b>8</b><br /> array(0) { } array(2) { [0]=> string(25) "q=bus%20online%20booking&" [1]=> string(22) "bus%20online%20booking" }