str_replace only after first space and not after 2nd.
Posted: Thu Aug 03, 2006 2:53 pm
I'm working on something that is supposed to automatically format recipe abbreviations in a recipe submission database...
I am using str_replace to do this - -
for example
All is fine and dandy... but I realized while typing
1 C water
will produce
1 C. water
typing
1 C. Carrots
will produce
1 C. C.arrots
Is there a way in PHP where I can essentially say "look after the 1st blank space and not after the 2nd" ??
I'm a newb... sorry if this is a ridiculous question.... I'd like to have only one text area for the entire recipe...
I am using str_replace to do this - -
for example
Code: Select all
$recipeingredients = str_replace(" Cups", " C.", $recipeingredients);
$recipeingredients = str_replace(" cups", " C.", $recipeingredients);
$recipeingredients = str_replace(" Cup", " C.", $recipeingredients);
$recipeingredients = str_replace(" cup", " C.", $recipeingredients);
$recipeingredients = str_replace(" c", " C.", $recipeingredients);
$recipeingredients = str_replace(" C", " C.", $recipeingredients);1 C water
will produce
1 C. water
typing
1 C. Carrots
will produce
1 C. C.arrots
Is there a way in PHP where I can essentially say "look after the 1st blank space and not after the 2nd" ??
I'm a newb... sorry if this is a ridiculous question.... I'd like to have only one text area for the entire recipe...