Created
May 6, 2012 14:58
-
-
Save durango/2622789 to your computer and use it in GitHub Desktop.
Just showing someone how to convert 1k10 to 1,010.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function money_commands($dep) { | |
| $total = 0; | |
| $dep = str_replace(',', '', $dep); | |
| preg_match_all('#[0-9]{1,}(m|M)#', $dep, $matches); | |
| foreach($matches AS $v) { | |
| foreach($v AS $val) { | |
| $x = str_ireplace('m', '', $val); | |
| $dep = str_replace($val, '', $dep); | |
| $total += $x*1000000; | |
| } | |
| } | |
| preg_match_all('#[0-9]{1,}(t|T|k|K)#', $dep, $matches); | |
| foreach($matches AS $v) { | |
| foreach($v AS $val) { | |
| $x = str_ireplace(array('k','t'), '', $val); | |
| $dep = str_replace($val, '', $dep); | |
| $total += $x*1000; | |
| } | |
| } | |
| preg_match_all('#[0-9]{1,}(h|H)#', $dep, $matches); | |
| foreach($matches AS $v) { | |
| foreach($v AS $val) { | |
| $x = str_ireplace('h', '', $val); | |
| $dep = str_replace($val, '', $dep); | |
| $total += $x*100; | |
| } | |
| } | |
| $total += $dep; | |
| if(!is_numeric($total)) $amount = 0; | |
| else $amount = $total; | |
| return $amount; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment