AngieX Posted December 1, 2006 Share Posted December 1, 2006 Hi, I want to assign a bunch of strings to a bunch of arrays so it looks like this in the looploop {....$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 More sharing options...
alpine Posted December 1, 2006 Share Posted December 1, 2006 Could something like this be what u're looking for ? ?[code]<?php$arr = array("array_one","array_two","array_three");foreach($arr as $arrkey => $arrvalue){ $string{$arrkey} = $arrvalue;}echo $string{0};echo $string{1};echo $string{2};?>[/code] Link to comment https://forums.phpfreaks.com/topic/29133-looparray-newbie-question/#findComment-133581 Share on other sites More sharing options...
AngieX Posted December 1, 2006 Author Share Posted December 1, 2006 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 = $dynamicarray4Maybe 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] } ?> Link to comment https://forums.phpfreaks.com/topic/29133-looparray-newbie-question/#findComment-133589 Share on other sites More sharing options...
kenrbnsn Posted December 1, 2006 Share Posted December 1, 2006 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 Link to comment https://forums.phpfreaks.com/topic/29133-looparray-newbie-question/#findComment-133597 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.