simple array query

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Kaps
Forum Newbie
Posts: 5
Joined: Thu Nov 12, 2009 12:09 pm

simple array query

Post by Kaps »

Dear All,

I would expect the following to produce the integers 0 to 10 & their respective squares. However it produces a blank screen. Any idea why ? thanks

Kaps

P.S I did try and use the code tags (and previewed the code before submission) but no joy. Does anybody know why ?

[code = php]
<?php


for($i=0;$i++;$i<10)
{
$squared[$i] = $i*$i;
printf("%d %d",$i,$squared[$i]);
}

print_r ($squared);





?>



User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: simple array query

Post by requinix »

Code: Select all

for($i=0;$i++;$i<10)
Got your condition and increment steps backwards.
Kaps wrote:P.S I did try and use the code tags (and previewed the code before submission) but no joy. Does anybody know why ?
No whitespace around the =s.
Kaps
Forum Newbie
Posts: 5
Joined: Thu Nov 12, 2009 12:09 pm

Re: simple array query

Post by Kaps »

Thanks. Much appreciated.

Kaps
Post Reply