Skip to content

Instantly share code, notes, and snippets.

@kimegede
Last active August 29, 2015 14:16
Show Gist options
  • Save kimegede/51e86abc863393c0eb57 to your computer and use it in GitHub Desktop.
Save kimegede/51e86abc863393c0eb57 to your computer and use it in GitHub Desktop.
CakePHP, Crud infinity test
<?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