Jump to content

Can someone explain the following line of code to me ?


jini01

Recommended Posts

$returnValue=preg_replace("/[^0-9 \d]/i", "", $text);

 

Note that there is also a space (' ') in the original code.  If that's correct, and you wish to maintain that functionality, you should also include it in MadTechie's example:

 

$returnValue = preg_replace('/[^\d ]/', '', $text);

 

Then it will only keep digits and spaces.

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.