*EDIT*
I would change the second and third lines from this:
CODE
for($i = 0; $i < $length; $i++){
$numbers = '';
to this:
CODE
$numbers = '';
for($i = 0; $i < $length; $i++){
As $numbers was being reset to '' in every instance of the loop.
*END EDIT*
To explain what grim's code does, it loops through the amount entered, checking each number / letter.
$temp is the ASCII value of the individual character of each number/letter in amount. e.g.
4734556
$temp on the first loop is the ASCII value of 4, 7 on the second loop, 3 on the third loop, 4 on the 4th etc.
So, if $temp is between 48 and 57, it is concidered a number (I'm assuming that 48 - 57 is the ASCII range of 0 - 9, don't know the ASCII values of the top of my head)
If it is in this range then it is a number, so it is appended to the variable $numbers.
So, if you where to enter this as the amount:
54asd65asd45
You would get 546545 as the $numbers value.
All in all a nice function that i think I'll be adding to my library, thanks grim
This post has been edited by pemcconnell: 1 Oct, 2008 - 04:52 AM