Jump to content

Str_Replace Help


the-botman

Recommended Posts

ok see i am trying to remove the number 16 , it removes the number but also removes it from the time which is wrong for example 16:45 , i just want it to remove the number 16 if its alone and not if it has : next to it this is what im using

$FGuide = str_replace("16", '', $FGuide);

 

thanks in advance

zainul

Link to comment
https://forums.phpfreaks.com/topic/269076-str_replace-help/
Share on other sites

For this you'll need to use RegExps, or at least if the number can appear with anything other than just spaces on either side.

 

The RegExp variant:

$FGuide = preg_replace ('/\\b16(?![:\\d])/', '', $FGuide);

 

That'll remove any number 16 which is not followed by a semi colon or another digit.

Link to comment
https://forums.phpfreaks.com/topic/269076-str_replace-help/#findComment-1382681
Share on other sites

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.