note 41020 added to function.preg-split
| From: | skibobdi at hotmail dot com | Date: | Fri, 26 Mar 2004 22:21:32 +0000 |
| Subject: | note 41020 added to function.preg-split | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-67211@lists.php.net to get a copy of this message | ||
Hi there, I am having currently making a template system in php to try and excel my coding skills a
bit and i'm having a bit of a problem, I've already spent hours trying to figure it out -
with no success :((...
the specific problem is this: I am extracting my html template file into a $string (this bit works
ok as i've checked the $string afterwards)..
a portion of my template file looks like so:
<TABLE>
<MYTAG_LOOP NAME='NAV_LINKS'>
<TR><TD>
<A HREF="<SIMP_LOOP_VAR NAME='URL'>"
TARGET="<SIMP_LOOP_VAR NAME='TARGET'>"><SIMP_LOOP_VAR
NAME='NAME'></A>
</TD>
</TR>
<br>
</MYTAG_LOOP>
</TABLE>
then I use a regular expression to chop up the string into portions of MY_TAG's and
html&text, like this:
$exp = '/([<+](\/)?MYTAG_+[^>]*[>+])+/';
$split_template_block = preg_split($exp, $string, -1, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
Now when I do a var_export($split_template_block), I get the following structure, notice the extra
'/' that has been added at key 11, I can't for the life of me stop it from doing
this!! :S
1 => '<TABLE>'
2 => '<MYTAG_LOOP NAME=\'NAV_LINKS\'>'
3 => '<TR><TD>
<A HREF="'
4 => '<MYTAG_LOOP_VAR NAME=\'URL\'>'
5 => '" TARGET="'
6 => '<MYTAG_LOOP_VAR NAME=\'TARGET\'>'
7 => '">'
8 => '<MYTAG_LOOP_VAR NAME=\'NAME\'>'
9 => '</A>
</TD>
</TR>
<br>'
10=> '</MYTAG_LOOP>'
11=> '/'
12=> '</TABLE>'
Any help from anyone, would be very greatly significantly appreciated..Andy. skibobdi@hotmail.com
----
Manual Page -- http://www.php.net/manual/en/function.preg-split.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41020
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41020&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41020&report=yes
Search -- http://master.php.net/manage/user-notes.php