Convert string into integer

3xtr3m3d used Ask the Experts™

Im reading two strings from a file to compare them, so i need to convert them into integers

if i read like this im getting 2 strings that i want
$x = $file[2];               (32212254720 )
$y = $file[3];               (8010207232)
when i convert them, im getting same values to both

$x= intval($file[2]);      (2147483647)
$y = intval($file[3]);     (2147483647)

i also tried with (int) but getting same result :(   strange thing is both ways works fine on my loacalhost :(

hope someone will understand my problem

sorry for language errors


Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
I think your localhost is 64 bit machine and actual server is 32 bit machine.

32 bit integers have maximum value of 2147483647, and that's the reason you're getting like that.

See "Return Values" section of


oh thanks for the info :) is there anyway to make this work?
You can use floatval().. but it won't be the same as intval().

What are you doing with the converted values?


comparing them whether they are <= with a javascript and showing error message
If it's just for comparison, try using floatval()


Thanks it works

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial