The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
For loop troubles
I need to make a for loop to access the contents of an array, but I don't know where to put it or if vbulletin has a special syntax for it.
The loop is for($i=0; $i < sizeof($contents); $i++) then I access the contents of the array inside a table. Do I put in the template? Or somewhere else? Any help will be greatly appreciated. |
#2
|
|||
|
|||
Code:
for($i =0 ; $i <= sizeof($contents); $i++) { $var .= "whatever"; $var2 .= "more Whatever" } |
#3
|
|||
|
|||
So every variable that's called must be within the for loop braces?
|
#4
|
|||
|
|||
If you want the variables to change based on the count, yes. The way I have it coded above with the .= the variable will simply be repeated for each count. so if the count = 4 placing $var in your template would render the word Whatever 4 times. and placing $var2 in your template will render more Whatever 4 times as well.
|
#5
|
|||
|
|||
well the variable i have to access is $contents[$i]->rating
And I tried doing $rating .= $contents[$i]->rating but that didn't work.... I'm getting the array from an included file, would I have to change all the variables in there from = to .= ? |
#6
|
|||
|
|||
Quote:
PHP Code:
If you have an array look at foreach()... http://us4.php.net/manual/en/control...es.foreach.php |
#7
|
|||
|
|||
It's not just a simple array like
PHP Code:
I just need to a detail way to access the variable of the array to the templates. Code:
<td> $contents[$i]->rating</td><td> $contents[$i]->runtime</td> |
#8
|
|||
|
|||
I'm gonna guess that you have to put those in singular variables before passing them to a template to be parsed.
|
#9
|
|||
|
|||
I'd agree with noppid. Put them into singular variables first.
|
#10
|
|||
|
|||
hmm if you use array's ill recommand you to use
the function foreach or each with combine of list... |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|