IT.COM

PHP auto correction?

Spaceship Spaceship
Watch
Impact
201
So I recently bought a nice script but it lacks one feature that I really want. I would like to have the page auto correct the user's entries such as:

MYDOMAIN.COM to mydomain.com
$50 to $50.00

If anyone needs me to post pieces of code, let me know. I'm not sure which ones I would include.

One more thing, I'm a total PHP n00b so feel free to talk to me like I know nothing (which is close to the truth).
 
1
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Need some more specifics, are those 2 fields entered seperately?

EG

Domain: MYDOMAIN.COM
Price: $50

If they are it's as simple as doing for the domain

Code:
strtolower($domain_var)

Which does what it says, converts the string to lowercase

$domain_var should be whatever it is being used to display the domain.

and for the money one it could be something like this

Code:
number_format(ltrim($price_var, '$'), 2)

This get rid of the $ before it, convert the final number to a standard number with 2 decimal points.

It also gets rid of the $ in it's final format so you'd need to just add it in before you display the number.

$price_var should be whatever it is being used to display the price.
 
3
•••
2
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back