str_replace met PHP code		
			
		
		 		
				
		
                        
                 
            
            
				
                
                    Koek (laatste wijziging 08/06/2009 19:22)                       
             
             
                        
                Nieuw lid 
				
				Hallo,
    
    
        
            
                
<?php
$text = 'Dit is de gebruikers lijst: {user_list}';
$search = '{user_list}';
$replace = '<?php include(\'user_list.php\'); ?>';
$content = str_replace($search, $replace, $text);
?>
 
             
            <?php 
$text  =  'Dit is de gebruikers lijst: {user_list}' ; 
$search  =  '{user_list}' ; 
$replace  =  '<?php include(\' user_list. php\'); ?>' ; 
 
?> 
 
         
     
  
              
        
		
				
		15 antwoorden 
                
                     
                
                    
		
		
	             
 
            
                    
                         
                    
                    
                        
                            Martijn (laatste wijziging 08/06/2009 19:24)                             
                         
                     
                    
                        Crew PHP  ' vervangen door ". Dus single door double 
                      
                
                    
                         
                    
                    
                        
                            Koek (laatste wijziging 08/06/2009 19:26)                             
                         
                     
                    
                        Nieuw lid Welke? Die buitenste? en dan de slashes weghalen? 
                      
                
                    
                         
                    
                    
                        
                            Martijn                             
                         
                     
                    
                        Crew PHP hmm dacht dat dat het was omdat alles tussen single letterlijk word genomen.
    
    
        
            
                $content = file_get_contents("user_list.php"); 
             
            
         
         
     
  
                      
                
                    
                         
                    
                    
                        
                            Koek                             
                         
                     
                    
                        Nieuw lid Helaas, werkt ook beide niet... 
                      
                
                    
                         
                    
                    
                        
                            Koek                             
                         
                     
                    
                        Nieuw lid Werkt ook niet helemaal soepel, en dan zou ik weer heel omslachtig m'n while-lus in één enkele variabele moeten zetten? 
                      
                
                    
                         
                    
                    
                        
                            Wim                             
                         
                     
                    
                        Crew algemeen Je kan het trouwens wel doen met preg_replace.  Dit heeft een optie (e) om php code te laten uitvoeren:
    
    
        
            
                $text= preg_replace ("_\{userlist\}_se", "include('user_list.php');", $text); 
             
            $text =  preg_replace ( "_\{userlist\}_se" ,  "include('user_list.php');" ,  $text ) ;  
         
     
  
                      
                
                    
                         
                    
                    
                        
                            Koek                             
                         
                     
                    
                        Nieuw lid Hm.. Heb nu dit:
    
    
        
            
                
<?php
$content = preg_replace ("_\{photo_album_list\}_se","include('content/photo_album_list.php');",$arr['content_text']);
echo $content;
?> 
             
            <?php 
$content  =  preg_replace ( "_\{photo_album_list\}_se" , "include('content/photo_album_list.php');" , $arr [ 'content_text' ] ) ; ?> 
 
         
     
  
                      
                
                    
                         
                    
                    
                        
                            Joost                             
                         
                     
                    
                        PHP expert 
    
    
        
            
                
<?php
$content = preg_replace ("#\{photo_album_list\}#se","include('content/photo_album_list.php');",$arr['content_text']);
echo $content;
?>
 
             
            <?php 
$content  =  preg_replace ( "#\{photo_album_list\}#se" , "include('content/photo_album_list.php');" , $arr [ 'content_text' ] ) ; ?> 
 
         
     
   
                
                    
                         
                    
                    
                        
                            Wim                             
                         
                     
                    
                        Crew algemeen Koek  schreef:
Hm.. Heb nu dit:
    
    
        
            
                $content = preg_replace ("_\{photo\_album\_list\}_se","include('content/photo_album_list.php');",$arr['content_text']); 
             
            $content  =  preg_replace ( "_\{photo\_album\_list\}_se" , "include('content/photo_album_list.php');" , $arr [ 'content_text' ] ) ;  
         
     
   
                
                    
                         
                    
                    
                        
                            Koek                             
                         
                     
                    
                        Nieuw lid 't Werkt in principe wel, maar... 
                      
                
                    
                         
                    
                    
                        
                            Wim                             
                         
                     
                    
                        Crew algemeen en wat als je gebruik maakt van file_get_contents ipv include? 
                      
                
                    
                         
                    
                    
                        
                            Koek                             
                         
                     
                    
                        Nieuw lid Werkt ook niet zoals ik het wil... 
                      
                
                    
                         
                    
                        
		
		
	             
 
                
Dit onderwerp is gesloten .