Loops and Classes


Posted on 16th Feb 2014 07:03 pm by admin

I am making a template system and everything seems to be going well up until I have to loop in a variable where things starts to go weird. I need ideas on how to solve this.

It is not picking up variables where it changes within the loop.

Ie...

Code: for ($i=0;$i<3; $i++) {
$body->loop_blocks('test_area', array(
"TEST" => $i,
"TEST2" => $test2)
);
}
It picks up TEST2 variable as it remains constant, but TEST variable remains at 0.

Code: function loop_blocks($blockname, $array = array()) {

$this->$_blockdata[$blockname . "."] = $array;

foreach ($this->$_blockdata[$blockname . "."] as $tags => $data) {
$this->_looparray[$blockname . "."] = ereg_replace("{" . $tags . "}", $data, $this->_looparray[$blockname . "."]);
}

return true;
}
$this->_looparray[$blockname . "."] is where a particular block of HTML Code needs to be repeated for a loop.

Any thoughts?

No comments posted yet

Your Answer:

Login to answer
331 Like 13 Dislike
Previous forums Next forums
Other forums

Progress bar tracking file downloads
Hey guys, was wondering if there was a way to track how far a file has been downloaded. I know there

records between 2 dates
Hello all,

I have a date tracked table which contains effective_start_date and effective

MySQL Does not UPDATE- SQLString Problem
vb Syntax (Toggle Plain Text) 1. SQL = "UPDATE sampletable SET column1 = 'C1sample1'"

PHP login form help (Done Most of It)
Hi i am having a problem, when i try logging in it is always saying "Invalid Login" im not

Create or replace package is ending ORA-21700
Database 9.2.0., patch 8 (9.2.0.8.0).
I trying run
create or replace package ....etc.

C problem struct and string
Hi guys,

This is my first post and I'm hoping the experts here can help me solve my problem.<

Parse Error
Hi Guys,

I have a function in my class which returns a string link variable. The problem is i

Else statement screws up all css
Does anyone know what goes wrong in the process with this php code?
This code seems to be causing

Help with syntax
Hi all!

The $bridge variable is not getting passed while it is contained in the line below:

Strip Slashes Help
I've got a script that i've downloaded of the net to edit multiple fields from my sql database, and

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash