By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,144 Members | 872 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,144 IT Pros & Developers. It's quick & easy.

Scope Woes - IF statement nested in WHILE statement -PHP

P: 7
Scope Woes - IF statement nested in WHILE statement -PHP

I have an array $actuals_sum.
<?php
while(conditions)
{


if($i == '24)
{

$actuals_sum[$j] = 'bar';

$j = $j + 1;
}

}


echo $actuals_sum[1];

?>
---------


but.... it throws an ERROR and says $actuals _sum is undefined....

So the scope is LOCAL, i need to make it return GLOBAL.

-Hyrum
Reply With Quote
Apr 25 '07 #1
Share this Question
Share on Google+
1 Reply

tolkienarda
100+
P: 316
Scope Woes - IF statement nested in WHILE statement -PHP

I have an array $actuals_sum.
<?php
while(conditions)
{


if($i == '24)
{

$actuals_sum[$j] = 'bar';

$j = $j + 1;
}

}


echo $actuals_sum[1];

?>
---------


but.... it throws an ERROR and says $actuals _sum is undefined....

So the scope is LOCAL, i need to make it return GLOBAL.

-Hyrum
Reply With Quote

you aren't entering your if statement cause you have single quote before the 24 it you want to check if it is a string then you will need another single quote if you want it to be an int then you need to get rid of the first single quote

eric
Apr 25 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.