Jump to content


Photo

The 0 (Zero) Value being omitted


  • Please log in to reply
2 replies to this topic

#1 Techmaster

Techmaster
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 09 March 2006 - 04:34 AM

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

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

prints null or nothing

Another Example

$border = range(0,10);
The array ommits the 0 (Zero)
Any Ideas

#2 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 09 March 2006 - 04:44 AM

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 )

<?
$border = range(0,10);
print_r($border);
?>

Likewise, I tried your first bit of code, print_r the result and got:
Array ( [border] => --none-- ) 0

<?
$settings[border]="--none--";
if($settings[border]=="--none--") $border = "0";
else $border = $settings[border];
print_r($settings);
print_r($border);
?>


#3 Techmaster

Techmaster
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 09 March 2006 - 05:03 AM

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

<?
$border = range(0,10);
print_r($border);
?>

Thanks you post let me find the error the settings was declared after the if statment (working to long)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users