Reply to Re: loop question

Your name:

Reply:


Posted by J.O. Aho on 12/01/06 20:35

ia wrote:

> I am sorry I may not be clear. Bascially the problem I was trying to
> explain is I am assigning multiple $strings to multiple arrays, so
> therefore I need a way to assign multiple string counts like ($string1
> $string2 ---- not $string[1] $string[2] to such arrays.)
>
> How do you get PHP to work this way?
>
> in a loop {
>
> $string1 = $array1
> $string2 = $array2
> $string3 = $array3
> $string4 = $array4
> $string...
>
> }
>
> How do I get the count affixed to the $string1 without expressing it
> like $string[x]

If looking what you written here, you want a variable, not an arrya, that has
a numerical value which increases for each loop

/* the text part of the string name */
$variablename="stupidstring";
/* use the type of loop you need */
for($i=0; $i<10; $i ++) {
$newvarablename= $variablename . $i;
$$newvarablename="stupid string";
}

This will create you 10 variables with the names
stupidstring0, stupidstring1 to stupidstring9, all containing the value
"stupid string".

If this isn't what you wanted to do, then explain again what you want, give us
a more proper how you want things to look when finished.


//Aho

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация