fork(2) download
  1. <?php
  2.  
  3.  
  4. $str = <<<'EOF'
  5. function testfunc($text) {
  6.   if ($text) {
  7.   return 1;
  8.   }
  9.   return 0;
  10. }
  11. EOF;
  12. if ( preg_match('/ (function [^{]+ ) ( \{ (?: [^{}]* | (?-1) )* \} ) /x', $str, $m) )
  13. print_r ($m);
  14.  
  15. ?>
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
Array
(
    [0] => function testfunc($text) {
   if ($text) {
       return 1;
   }
   return 0;
}
    [1] => function testfunc($text) 
    [2] => {
   if ($text) {
       return 1;
   }
   return 0;
}
)