Jump to content

preg replace question


ballhogjoni

Recommended Posts

Hi all, I want my code to replace all characters accept for 0-9 and the period. This is my code so far, I just don't know where to place the period so that preg replce knows to keep it.

 

// say the user submitted this to post amount: 43%$3&*(.98
$string = preg_replace("/[^0-9s]/", "", $_POST['amount']);
// I want my script to echo 433.98

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/95831-preg-replace-question/
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.