[ create a new paste ] login | about

Link: http://codepad.org/dNryQWWm    [ raw code | output | fork ]

PHP, pasted on Mar 5:
1
2
3
4
5
6
7
8
<?php
$a = array('-1','-1.00','-1.11','1e4','1e40');

var_dump(array_map('is_integerable',$a));

function is_integerable( $v ){
  return is_numeric($v) && $v*1 == (int)($v*1);
}


Output:
1
2
3
4
5
6
7
8
9
10
11
12
array(5) {
  [0]=>
  bool(true)
  [1]=>
  bool(true)
  [2]=>
  bool(false)
  [3]=>
  bool(true)
  [4]=>
  bool(false)
}


Create a new paste based on this one


Comments: