pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

PHP pastebin - collaborative debugging tool View Help


Posted by Anonymous on Mon 6 Oct 18:38
report abuse | download | new post

  1. <pre>
  2. <?php
  3. function checktables($html){
  4.   $tables=preg_match_all('/<table /i',$html,$matches);
  5.   $withsummary=preg_match_all('/<table [^>]*\bsummary=/i',$html,$matches);
  6.   if($tables==$withsummary){
  7.     $withsummary="all";
  8.   }
  9.   echo "I found $tables tables and $withsummary of them have summary atttribute.<br>";
  10. }
  11. $file='<table border="4" summary="Hi"></table><table border="7" summary="Hi33443"></table>';
  12. checktables($file);
  13. $file='<table border="4"></table><table border="7" summary="Hi33443"></table>';
  14. checktables($file);
  15. function checkth($html){
  16.   $thcount=preg_match_all('#<th>#i',$html,$ths);
  17.   $withabbr=preg_match_all('#<th>(?:(?!</th>).)*<abbr #is',$html,$ths);
  18.   echo ($thcount==$withabbr) ? "Every th element I found had abbr attribute" : "I found th element with no abbr attibute";
  19.   echo "<br>";
  20. }
  21. $file='<table border="4"><tr><th><abbr title="et cetera">etc.</abbr></th></tr></table><table border="7" summary="Hi33443"></table>';
  22. checkth($file);
  23. $file='<table border="4"><tr><th><abbr title="et cetera">etc.</abbr></th></tr></table><table border="7" summary="Hi33443"><tr><th>etc.</th></tr><tr><th><abbr title="yes">yeap.</abbr></th></tr></table>';
  24. checkth($file);
  25. ?>

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post