Untitled
By: a guest | Oct 6th, 2008 | Syntax:
PHP | Size: 1.18 KB | Hits: 525 | Expires: Never
<pre>
<?php
function checktables($html){
$withsummary=preg_match_all('/<table [^>]*\bsummary=/i',$html,$matches);
if($tables==$withsummary){
$withsummary="all";
}
echo "I found $tables tables and $withsummary of them have summary atttribute.<br>";
}
$file='<table border="4" summary="Hi"></table><table border="7" summary="Hi33443"></table>';
checktables($file);
$file='<table border="4"></table><table border="7" summary="Hi33443"></table>';
checktables($file);
function checkth($html){
echo ($thcount==$withabbr) ? "Every th element I found had abbr attribute" : "I found th element with no abbr attibute";
echo "<br>";
}
$file='<table border="4"><tr><th><abbr title="et cetera">etc.</abbr></th></tr></table><table border="7" summary="Hi33443"></table>';
checkth($file);
$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>';
checkth($file);
?>