Jump to content

The 0 (Zero) Value being omitted


Techmaster

Recommended Posts

I have simple scripts that handle int values and for some reason the 0 (Zero) are being ommited
Value is --none--

[code]
if($settings[border]=="--none--") $border = "0";
else $border = $settings[border];
[/code]

prints null or nothing

Another Example

[code]
$border = range(0,10);
[/code]
The array ommits the 0 (Zero)
Any Ideas
Link to comment
https://forums.phpfreaks.com/topic/4503-the-0-zero-value-being-omitted/
Share on other sites

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 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)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.