- substr: documentation ( source)
- strpos: documentation ( source)
- preg_replace: documentation ( source)
<?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 + 4) . ' # ' . substr($itemFullName, $end);
echo "strpos()/substr(): " . $itemAttributes;
}