- strpos: documentation ( source)
- preg_replace: documentation ( source)
<?php
$title = "1 Gal. Black PE Grow Bag (100 per pack)";
$quantityarr = ["10", "100"];
foreach($quantityarr as $quantity){
if (strpos($title, $quantity . " ") !== false) {
}else{
$title = preg_replace('/\([\s\S]+?\)/', '', $title);
}
echo $quantity . ": " . $title. "\n";
$title = "1 Gal. Black PE Grow Bag (100 per pack)";
}