PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
fastfingertips
Forum Contributor
Posts: 242 Joined: Sun Dec 28, 2003 1:40 am
Contact:
Post
by fastfingertips » Tue Mar 21, 2006 9:34 am
Hello i have following string:
Code: Select all
<html>
<head>
<title><<:title:>></title>
</head>
<body>
<<:foreach (:user: as $key=>$value):>>
<tr>
<td><<:user:username:>></td>
<td><<:user:password:>></td>
<td><<:user:email:>></td>
</tr>
<<:endfor:>>
</body>
</html>
And i will like to use preg_split to separate:
Code: Select all
<<:foreach (:user: as $key=>$value):>>
<tr>
<td><<:user:username:>></td>
<td><<:user:password:>></td>
<td><<:user:email:>></td>
</tr>
<<:endfor:>>
From the rest of the code. My question is how to make the regex because no matter what i've tried i failed
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Mar 21, 2006 10:09 am
Code: Select all
$foo = preg_split('#(<<:foreach.+?<<:endfor:>>)#is', $text, PREG_SPLIT_DELIM_CAPTURE);
fastfingertips
Forum Contributor
Posts: 242 Joined: Sun Dec 28, 2003 1:40 am
Contact:
Post
by fastfingertips » Wed Mar 22, 2006 1:25 am
Thank you feyd but my problem is the same. That portion (<<:foreach ---- endfor:>>) i want to be storred in a different array element. As it seems i cannot avoid preg_match
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Mar 22, 2006 1:44 am
no you don't.
Code: Select all
$foo = preg_split('#(<<:foreach.+?<<:endfor:>>)#is', $text, -1, PREG_SPLIT_DELIM_CAPTURE);works, I just tried it. (I forgot the
limit argument in my previous post.)
fastfingertips
Forum Contributor
Posts: 242 Joined: Sun Dec 28, 2003 1:40 am
Contact:
Post
by fastfingertips » Wed Mar 22, 2006 1:46 am
Yhea indeed is working i also tried.
Please send me your address to knowe where should i send the bax with your favourite beer
.
This problem has been solved.
Thank you