Jump to content

How do do a str_replace on this?


Jeffro

Recommended Posts

  Quote

You'll want to use regex

$str = "all 6 news updates";
$number = preg_replace('/all (\d+) news updates/', '$1', $str);

echo "Echo the number is: $number";

 

What do you want replace the number with?

 

Actually, I'm not wanting to replace the number.  I want to find all instances of that entire phrase (regardless of the number that I find) and blank it out. 

$description=str_replace('all 6 news updates','',$description)

 

...keeping in mind that the number could be anything, which is why I can't use the code as I've just written it. 

 

Thanks!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.