php_joe Posted December 30, 2007 Share Posted December 30, 2007 Do leading zeros matter in array keys? is $var[04] the same as $var[4]? Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted December 30, 2007 Share Posted December 30, 2007 They shouldn't matter unless they are passed as a string...e.g. : $var['04'] != $var[04] Quote Link to comment Share on other sites More sharing options...
Barand Posted December 30, 2007 Share Posted December 30, 2007 Even if numeric they are not the same. <?php $a = array(); $a[010] = 'Hello'; $a[10] = 'World'; echo '<pre>', print_r($a, true), '</pre>'; ?> --> Array ( [8] => Hello // 010 is octal for 8 [10] => World ) [/pre} Quote Link to comment Share on other sites More sharing options...
php_joe Posted December 30, 2007 Author Share Posted December 30, 2007 Even if numeric they are not the same. Hmm... in that case is there a function that strips leading zeros off of numbers? Quote Link to comment Share on other sites More sharing options...
Barand Posted December 30, 2007 Share Posted December 30, 2007 intval() Quote Link to comment Share on other sites More sharing options...
php_joe Posted December 30, 2007 Author Share Posted December 30, 2007 intval() Thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.