3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $id = 'EPSON EB 955WH'; $id = preg_replace('#[^0-9A-Za-z]+#', '-', $id); $id = preg_replace('#^[^0-9A-Za-z]+|^[^0-9A-Za-z]+$#', '', $id); $id = strtoupper($id); var_dump($id); if (($pos = strpos('-APOG-PRO-GEN', $id)) !== -1) { $id = 'HLG-' . substr($id, 0, $pos); var_dump($pos); } else { $id = 'HL-' . $id; } var_dump($id);
Output for 5.6.0 - 7.3.0alpha1
string(14) "EPSON-EB-955WH" bool(false) string(4) "HLG-"