3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function sphinxesc($x){ $depth = 0; for ($i = 0; $i < strlen($x); ++$i){ $depth += $x[$i] == '(' ? 1 : 0; $depth -= $x[$i] == ')' ? 1 : 0; } if($depth != 0) $x = str_replace(array('(',')'),' ',$x); $x = str_replace(array('/','~','@'), ' ',$x); $x = preg_replace('/[\!\-\^]+(?!\w)/', ' ',$x); return $x } echo sphinxesc('hi! this is shit!');
based on RJA5t
Output for 7.0.0 - 7.0.1
Parse error: syntax error, unexpected '}', expecting ';' in /in/RNW9J on line 15
Process exited with code 255.
Output for 5.3.21 - 5.6.16
Parse error: syntax error, unexpected '}' in /in/RNW9J on line 15
Process exited with code 255.