Jump to content

Loop/array newbie question


AngieX

Recommended Posts

Hi, I want to assign a bunch of strings to a bunch of arrays so it looks like this in the loop

loop {....

$string1 = $arrayone;
$string2 = $arraytwo;
$string3 = $arraythree;
$string4 = $arrayfour;
$string....etc

}

I *don't* want to express $string1 like $string[$var].... I want something like "$string1 . $var" so it's simply assigning a string to a array which I will decompose later. 

How do I get this to work?  :)

Have wonderful day!  -Angie
Link to comment
https://forums.phpfreaks.com/topic/29133-looparray-newbie-question/
Share on other sites


It's more like this:

a for loop which captures 1 or more $dynamicarray(s), and assigns them to a variable $string.

$stringA = $dynamicarray1
$stringB = $dynamicarray2
$stringC = $dynamicarray3
$stringD = $dynamicarray4

Maybe I was being too confusing asking for $string1, $string2.... but either way will work.

The code would be wrapped in this:


<? $countx=0; while($countx<$count){  [b][color=purple][color=green]...this $stringA,B,C assigned to $dynamicarray(s) would go here...[/color][/color][/b] } ?>


Why don't you want to used arrays for this. Using arrays would make coding much easier:
[code]<?php
$string = array();
$string[1] = $dynamicarray1;
$string[2] = $dynamicarray2;
$string[3] = $dynamicarray3;
$string[4] = $dynamicarray4;
?>[/code]

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.