fork download
  1. <?php
  2. function addTwo($a)
  3. {
  4. return "include {$a[0]}.php";
  5. }
  6.  
  7.  
  8. $str = '[INCLUDE]page1[/INCLUDE]';
  9.  
  10. $result = preg_replace_callback('/(page\d)/', 'addTwo', $str);
  11.  
  12. echo $result;
Success #stdin #stdout 0.02s 23752KB
stdin
Standard input is empty
stdout
[INCLUDE]include page1.php[/INCLUDE]