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
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]
Link to comment
Share on other sites

[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)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.