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

How to use Substr
I want to check for the word CATEGORY: inside a string which can be CATEGORY: ITEM
and remove the

Any meaningful project for a new C++ programmer?
I want to do some meaningful program, so I can help myself to learn

Assume I know the fol

Including calander to page - will not show other months than current??
im trying to add an existaing calander onto a profile page by using Code: <?php include "

[function.file]: failed to open stream: No such file or directory
Okay I wrote this little script to upload a csv file that is located on my webhosts server to a mysq

Undefined Variable: PHP_SELF, pls help
Hi,

Im a newbie on PHP / MySQL programming and Im running a script to search one field on my

values not being entered into table
hi. I;ve created a form, so that when a user enters data into it, it gets added to a table in a data

button help
i originally had this but realised it is much easier to have a button.

Code: <?php

cURL Sending File as Post
This is a bit complicated, I'm just hoping someone else has run into this and knows how to do it a d

PHP switch function help
Hi, I am trying to create a search function for a directory website. On the search function on html

using explode() to fill in checkboxes
Hi

I have a field stored in a table that contains regions in the UK separated by commas. Ther

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