3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = "destination=Apartment+TITLIS+Resort+Wohnung+721&hotelid=0123454656"; if (($pos = strpos($data, "=")) !== FALSE) { $whatIWant = ucwords(substr($data, $pos+1)); $whatIWant = explode("&", $whatIWant); $whatIWant = $whatIWant[0]; echo "Ans1: \n"; echo $whatIWant; // Output: Apartment+TITLIS+Resort+Wohnung+721 // if you want your output with & just add & echo "\n\nAns2: \n"; $whatIWant = $whatIWant."&"; echo $whatIWant; // now Output iss: // Apartment+TITLIS+Resort+Wohnung+721& } ?>

preferences:
55.13 ms | 402 KiB | 5 Q