fork(1) download
  1. <?php
  2.  
  3. $input1 = <<<__EOT
  4. <!-- comments disabled -->
  5. <!-- comments enabled -->
  6. __EOT;
  7.  
  8. $input2 = <<<__EOT
  9. <!-- comments enabled -->
  10. <!-- comments disabled -->
  11. __EOT;
  12.  
  13. function commentsEnabled($str){
  14. preg_match_all('/^.*?<!--\s*comments\s+(en|dis)abled\s*-->.*$/m', $str, $m);
  15. return !count($m[1]) ? null : array_pop($m[1]) == 'en';
  16. }
  17.  
  18. if(commentsEnabled($input1)===true) echo "yay\n";
  19. if(commentsEnabled($input2)!==true) echo ':(';
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
yay
:(