Masonbarge, I would tend to move all of your specific text OUT into a separate and easy to maintain data file rather than leave it in the program - the data might look like:
- Code: Select all
allpurp,all-purpose,
and , & ,
appl , apple ,
asprt,aspatame,
bf,beef,
bn,bean,
etc
and then the conversion could be shortened to:
- Code: Select all
<?php
$food_name = " appl and bf pie";
print ("$food_name<br>\n");
foreach (file("changeit.txt") as $line) {
list($change,$into) = explode(",",$line);
$food_name = preg_replace("/$change/i",$into,$food_name);
}
print ("$food_name<br>\n");
?>
Of course, if you get paid by the line of code written or want to retain control in the programmer's hands, this approach probably isn't for you
