3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $code = 'fr_fr'; var_dump(false === ($pos = strpos($code, '_')) ? $code : substr($code, 0, $pos)); $code = 'fr'; var_dump(false === ($pos = strpos($code, '_')) ? $code : substr($code, 0, $pos)); $code = '_fr'; var_dump(false === ($pos = strpos($code, '_')) ? $code : substr($code, 0, $pos));
Output for 4.3.0 - 7.2.0
string(2) "fr" string(2) "fr" string(0) ""