0

I am in the hard task of rewriting a template system, specificly to support repeating content of a forum script.

I am currently tyring this with a dummy file at the moment and I am stuck on one part.
What is basically does, is load the following html which has worked well, but what I need to do is a value where it cuts the html between 2 tags so I can use it to be repeated before reinserting.

$string = '<div class="boxone">Memberlist</div>

<!-- row -->
Username is {USERNAME}
<!-- row -->';

So in short, what I am looking to do is cut 'Username is {USERNAME}' out of the string, preferbly in a function, so I would end up with something similar to bellow

$snippet = bock('row',$string);
print $snippet; // outputs Username is {USERNAME}

Any help would be appreciated

3
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by Mi-Dia
0

I looked at that first, but thats only replacing, what I need is the opposite.
Instead of replacing, I want it to find whats between the html comments and return it to me.

Edited by Mi-Dia: n/a

0

Anyone. I basically want to make it so I have 1 template file per page, and make a function to repeat a certain bit for rows or posts ect.

So I need a function where it can look at a string, find the html between the html comments then return it as a usable var

0

Anyone, theres got to be a way to do this, it was done in phpbb2. Its not rocket science but looking through php.net I cant find the right function.

0

Anyone. I basically want to make it so I have 1 template file per page, and make a function to repeat a certain bit for rows or posts ect.

So I need a function where it can look at a string, find the html between the html comments then return it as a usable var

You could search for a pattern, for example search for the opening tag then put the position of that into a variable, then find the closing tag and take the position of that. Then withdraw the position of the closing tag from the position of the opening tag.
This way you have the start position and the length of what is between and can use the substr function to fetch what is in there.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.