public
Last active — forked from bxt/numberconv.php

  • Download Gist
numberconv.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
<?php
 
$strs=array('1','10','10a10','a12','a','10E3','4.6','4,6','4%6');
foreach ($strs as $str) {
$int=(int)$str;
$by1=$str*1;
$iv=intval($str);
echo "$str\tint:\t$int\tby1:\t$by1\tintval:\t$iv\n";
}
 
/*
Output:
 
1 int: 1 by1: 1 intval: 1
10 int: 10 by1: 10 intval: 10
10a10 int: 10 by1: 10 intval: 10
a12 int: 0 by1: 0 intval: 0
a int: 0 by1: 0 intval: 0
10E3 int: 10 by1: 10000 intval: 10
4.6 int: 4 by1: 4.6 intval: 4
4,6 int: 4 by1: 4 intval: 4
4%6 int: 4 by1: 4 intval: 4
 
*/

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.