Posted by Craig Taylor on 01/12/07 03:31
alka...@gmail.com wrote:
> Hi, can someone please show me how to assign a standard $var, to the
> contents of a for loop like,
>
> for ($a=0; $a<10; $a++){ $array[$a]; }
>
> :)
>
> so, I wanted something like
>
> $var = for ($a=0; $a<10; $a++){ $array[$a]; }
>
> but it doesn't work. thanks for a push in the right direction! :)
Not quite sure what you're trying to do but one of the following 2
probably fit the bill:
To assign a value ($val) to each element in the array:
for( $a=0; $a<10; $a++) { $array[$a] = $val; }
To assign an array containing the digits 0-9 to $val do the following:
$val = array();
for( $a = 0; $a<10; $a++) { $val[] = $a; }
Hope 1 of these help...
- Craig Taylor
http://www.ctalkobt.net
[Back to original message]
|