View Full Version : Convert number as string to number?
04-16-2012, 09:07 PM
I just figured out how to use settype....
04-16-2012, 09:24 PM
PHP automatically converts based on context. So adding two strings of numbers results in a number. This is IMO a tremendous weakness of using datatype weak languages.
For explicit, I'd cast directly using (int) or (float) if you need to. Settype is a tad on the temperamental side. Even using an intval() would be better.
04-16-2012, 10:48 PM
$num = parseInt('f',16);
$num = base_convert('f', 16, 10);
Neither has anything to do with converting strings to numbers.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.