Help parsing a template/if statement

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

Post Reply
THESiUS
Forum Newbie
Posts: 6
Joined: Wed Mar 17, 2004 2:53 am

Help parsing a template/if statement

Post by THESiUS »

Code: Select all

$test_string = '
	Some text goes here
	<br>
	<br>
	<if $whatever>
		Test text
		<br>
	</if>
	 Some more text
';
I have this template I made and I am trying to parse out everything between that if statement. So that it looks something like this...

Code: Select all

$test_string = '
	Some text goes here
	<br>
	<br>
	 Some more text
';
Thanks for any help I get.
TheBentinel.com
Forum Contributor
Posts: 282
Joined: Wed Mar 10, 2004 1:52 pm
Location: Columbus, Ohio

Post by TheBentinel.com »

the strpos() function can help you find the <if> and the </if> tags, then you can use a couple of substr()'s to pull the data out.

http://www.php.net/strpos
http://www.php.net/substr
Post Reply