Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>i would use a bitmask for this: <a href="http://php.net/manual/en/language.operators.bitwise.php" rel="nofollow">http://php.net/manual/en/language.operators.bitwise.php</a></p> <pre><code>&lt;?php // define your types and groups: $listedTypes["TYPE_MSWORD"] = 1; $listedTypes["TYPE_MSEXCEL"] = 2; $listedTypes["TYPE_MSPOWERPOINT"] = 4; $listedTypes["TYPE_OFFICE"] = $listedTypes["TYPE_MSWORD"] + $listedTypes["TYPE_MSEXCEL"] + $listedTypes["TYPE_MSPOWERPOINT"]; $listedTypes["TYPE_HTML"] = 8; $listedTypes["TYPE_SVG"] = 16; $listedTypes["TYPE_W3C"] = $listedTypes["TYPE_HTML"] + $listedTypes["TYPE_SVG"]; $listedTypes["TYPE_ALL"] = $listedTypes["TYPE_OFFICE"] + $listedTypes["TYPE_W3C"]; // try to open the page.php?doctype=TYPE_MSWORD // or page.php?doctype=TYPE_ALL if(!isset($_GET['doctype'])) $_GET['doctype'] = "TYPE_ALL"; if(!isset($listedTypes[$_GET['doctype']])) $_GET['doctype'] = "TYPE_ALL"; $requestedType = $listedTypes[$_GET['doctype']]; foreach ( $files as $file ) { $xml = new SimpleXMLElement( $file, 0, true ); if($xml-&gt;doctype == "......") $fileType = $listedTypes["TYPE_MSWORD"]; elseif($xml-&gt;doctype == ".........") $fileType = $listedTypes["TYPE_MSEXCEL"]; elseif($xml-&gt;doctype == ".........") $fileType = $listedTypes["TYPE_MSPOWERPOINT"]; //... continue // then check if the $type matches the $selection of $_GET['doctype'] // if the filetype is in the requested file type group, it will be shown if($fileType &amp; $requestedType) { echo' &lt;tr&gt; &lt;td id="'. $xml-&gt;doctype .'" name="'. $xml-&gt;doctype .'" class="mainTable"&gt;' . $xml-&gt;doctype . '&lt;/td&gt; &lt;td&gt;&lt;a href="viewdoc.php?docname=' . basename( $file, '.xml' ) . '&amp;username='. $xml-&gt;startedby .'&amp;myname='. $_SESSION['username'] .'"&gt;' . basename( $file, '.xml' ) . '&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;a href="viewprofile.php?name='. $xml-&gt;startedby .'"&gt;'. $xml-&gt;startedby .'&lt;/a&gt;&lt;/td&gt; &lt;td&gt;'. $xml-&gt;date .'&lt;/td&gt; &lt;td&gt;* * * * *&lt;/td&gt; &lt;td&gt;'. filesize( $file ) .'kb&lt;/td&gt; &lt;/tr&gt; '; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload