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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.