Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as PHP by bramaudi ( 9 years ago )
<?php
// File atau sumber template
$file = "
<ul>
[post]
<li>
 <b>[title]</b>
 <br>
 [text]
</li>
[/post]
</ul>
";

// Fungsi
$hasil = preg_replace_callback('(\[post\](.*)\[/post\])is','tpl',$file);

function tpl($cocok) {
 
 $array = array();
 
 // Implementasi looping database
 $array[] = array(
 'title' => 'Hello World',
 'content' => 'This is my first post.'
 );
 
 $array[] = array(
 'title' => 'Lorem Ipsum',
 'content' => 'Just another post.'
 );
 
 // Menyiapkan array replacement
 for($i=0;$i<count xss=removed> $array[$i]['title'],
  '[text]' => $array[$i]['content']
  );
 
 // Proses replace untuk tag
 @$result .= str_replace(array_keys($re), array_values($re), $cocok[1]);
 }
 
 return $result;
 
}

echo $hasil;

 

Revise this Paste

Your Name: Code Language: