3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $itemFullName = "10-16X4 POLI MG SELF START BLK PLASTIC"; $itemAttributes = preg_replace("@POLI.+?BLK@", "#", $itemFullName); echo 'Regex: ' . $itemAttributes . "\n"; if (false !== ($start = strpos($itemFullName, 'POLI')) && false !== ($end = strpos($itemFullName, 'BLK', $start))) { $itemAttributes = substr($itemFullName, 0, $start) . ' # ' . substr($itemFullName, $end + 3); echo "strpos()/substr(): " . $itemAttributes; }
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Regex: 10-16X4 # PLASTIC strpos()/substr(): 10-16X4 # PLASTIC