Question

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! :)
alkalsa [ Fr, 12 Januar 2007 03:46 ] [ ID #1593515 ]

Re: Question

alka... [at] 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
ctalkobt [ Fr, 12 Januar 2007 04:31 ] [ ID #1593533 ]

Re: Question

Maybe something like this concept:

Imagine array called $array,

it contains 5 data bits

$array[0] = "blue"
$array[1] = "green"
$array[2] = "red"
$array[3] = "yellow"
$array[4] = "orange"

I want to convert $array, to $string. It shouldn't be an array inside
$string, and should by default look like this:

print $string

results in

bluegreenredyelloworange

Sorry I wasn't understandable in my first post :-)

I really appreciate your help! :)
alkalsa [ Fr, 12 Januar 2007 05:42 ] [ ID #1593545 ]

Re: Question

Message-ID: <1168576947.763566.314530 [at] q2g2000cwa.googlegroups.com> from
alkalsa [at] gmail.com contained the following:

>$array[0] = "blue"
>$array[1] = "green"
>$array[2] = "red"
>$array[3] = "yellow"
>$array[4] = "orange"
>
>I want to convert $array, to $string. It shouldn't be an array inside
>$string, and should by default look like this:
>
>print $string
>
>results in
>
>bluegreenredyelloworange

$string=implode("",$array);

--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
Geoff Berrow [ Fr, 12 Januar 2007 06:40 ] [ ID #1593548 ]

Re: Question

> $string=implode("",$array);
>

Ah Cheers Geoff - that was the command I was forgetting :-)
alkalsa [ Fr, 12 Januar 2007 08:20 ] [ ID #1593555 ]
PHP » alt.php » Question

Vorheriges Thema: Best PHP IDE ?
Nächstes Thema: Image issues