James Freeman
Member
I'm currently working on a template system like xenForo's, I've got my code working partly, I'm kinda new to the whole preg_match and preg_replace..
Right, I'll show you some code..
test.tpl:
	
	
	
		
However it's being translated to..
	
	
	
		
My PHP code is as follows:
	
	
	
		
				
			Right, I'll show you some code..
test.tpl:
		Code:
	
	<curve:if condition="test">
    Hai
    <curve:else>
        had
    </curve:else>
</curve:if>
		Code:
	
	<curve:if condition="test">
    Hai
     <?php } else { ?>
        had
     <?php } else { ?>
</curve:if>My PHP code is as follows:
		PHP:
	
	<?php
        private function _handleElse ( )
        {
            $find = '#(<curve:if)(.*)(<curve:else>|</curve:else>)(.*)</curve:if>#is';
            $input = $this->_outPut;
            while( ( bool ) preg_match( $find, $input ) )
            {
                $input = preg_replace
                (
                    $find,
                    '<curve:if$2 <?php } else { ?> $4</curve:if>',
                    $input
                );
            }
            echo $input;die;
        } 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		