Page 1 of 1

simple array query

Posted: Sun Nov 15, 2009 3:27 am
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);





?>




Re: simple array query

Posted: Sun Nov 15, 2009 4:05 am
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.

Re: simple array query

Posted: Sun Nov 15, 2009 6:37 am
by Kaps
Thanks. Much appreciated.

Kaps