Searching text

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

Searching text

Post by anthony88guy »

http://nokidding.websiteallies.com/bankingcalc.html

I have a calculator that I have made, when someone enters a comma in with any of the text, it doesn't calculate right anymore. So how do i search text for a ","?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you mean enters a comma in a number? strip the text field of all non-numbers.. or error out..

Code: Select all

$text = preg_replace('#\D#', '', $text);
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

Post by anthony88guy »

I would like to know how to add comma's to numbers, and if someone enters a number with a comma is get rid of it.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Post Reply