Techmaster Posted March 9, 2006 Share Posted March 9, 2006 I have simple scripts that handle int values and for some reason the 0 (Zero) are being ommitedValue is --none--[code]if($settings[border]=="--none--") $border = "0";else $border = $settings[border];[/code]prints null or nothingAnother Example[code]$border = range(0,10);[/code]The array ommits the 0 (Zero)Any Ideas Quote Link to comment https://forums.phpfreaks.com/topic/4503-the-0-zero-value-being-omitted/ Share on other sites More sharing options...
michaellunsford Posted March 9, 2006 Share Posted March 9, 2006 I ran your second bit, which seems to work correclty. Here's the result and how I displayed it:Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 [7] => 7 [8] => 8 [9] => 9 [10] => 10 )[code]<?$border = range(0,10);print_r($border);?>[/code]Likewise, I tried your first bit of code, print_r the result and got:Array ( [border] => --none-- ) 0[code]<?$settings[border]="--none--";if($settings[border]=="--none--") $border = "0";else $border = $settings[border];print_r($settings);print_r($border);?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/4503-the-0-zero-value-being-omitted/#findComment-15669 Share on other sites More sharing options...
Techmaster Posted March 9, 2006 Author Share Posted March 9, 2006 [quote name='michaellunsford' date='Mar 8 2006, 11:44 PM' post='353139']I ran your second bit, which seems to work correclty. Here's the result and how I displayed it:Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 [7] => 7 [8] => 8 [9] => 9 [10] => 10 )[code]<?$border = range(0,10);print_r($border);?>[/code]Thanks you post let me find the error the settings was declared after the if statment (working to long) Quote Link to comment https://forums.phpfreaks.com/topic/4503-the-0-zero-value-being-omitted/#findComment-15677 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.