3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $autocomplete = "BD/AL/ABC/01/18 job developper"; $q = "lol reference=BD/AL/ABC/ test"; $expr = '/reference=\w*/'; $words = explode(' ', $q); $newQ = ''; foreach ($words as $word) { if (preg_match($expr, $word, $matches)) { $reference = str_replace('reference=', '', $word); echo $reference; } else { $newQ = $newQ . ' ' . $word; } } echo $newQ;
based on jRkmv
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.2.6
BD/AL/ABC/ lol test