Re: Newbie - Spot the error
| From: | Shaun Thomas | Date: | Wed, 15 May 2002 14:05:05 +0000 |
| Subject: | Re: Newbie - Spot the error | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-97719@lists.php.net to get a copy of this message | ||
On Wed, 15 May 2002, Josh Edwards wrote:
> $timespread =array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
> if ($time = = "21")
> $timespread[22]=($timespread[22]+1);
> echo $timespread[22] ;
It should be ==, not = =. Secondly, you don't need to quote the 21,
it's a number. You should use PHP's array_fill function to make your
array of 0's. Finally, remember the ++ syntax, too. Try this:
$timespread = array_fill(0, 24, 0);
if ($time == 21)
$timespread[22]++;
echo $timespread[22];
--
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
| Shaun M. Thomas INN Database Administrator |
| Phone: (309) 743-0812 Fax : (309) 743-0830 |
| Email: sthomas@townnews.com AIM : trifthen |
| Web : www.townnews.com |
| |
| "Most of our lives are about proving something, either to |
| ourselves or to someone else." |
| -- Anonymous |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+