Last active
August 29, 2015 14:16
-
-
Save kimegede/51e86abc863393c0eb57 to your computer and use it in GitHub Desktop.
CakePHP, Crud infinity test
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
<?php | |
function _castNumbers($variable) { | |
if (!is_numeric($variable)) { | |
return $variable; | |
} | |
$number = $variable + 0; | |
// Check if number is below infinity | |
return ($number < INF) ? $number : $variable; | |
} | |
$data = array( | |
'string' => 'abcdef', | |
'infinity' => '0113870020e12235', | |
'integer' => 1234 | |
); | |
foreach ($data as $key => $value) { | |
print $key . "\n"; | |
print _castNumbers($value) . "\n"; | |
print "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment