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 submit a form to the same page?
I have a table containing information about books in my library and this table has the following col

Shuffle Array
Hi,

I am writing a script for a game that needs players to randomly be assigned a target (ano

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

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

Is there a function ... auto send IP
Is there some function that can be sent to a ddns service that returns the ip address of a ddns forw

filesize() returns 0
I have a socket program that runs in an infinite loop, listening for connections, in this socket I h

How to use php and sql to check if values match the ones in a table (for logins)
How would I code it that the script takes two variables that are passed to it (UserID and PIN), and

Facebook status update API
Hello,

So, I'm trying to create my first Facebook application with PHP.

Basic ideas fo

What am I missing here? Help!
Hello all!. I can't seem to get this working right. Well - it renders right, but something is goin

Stumped by Third Day of Month problem
I am trying to build an algorithm that will essentially do this:
Code: [Select]$this_month = Oct

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