Use functions to query the names of all data tables used in the project

Source: Internet
Author: User

1<style>2 3 ul{4width:100%;;5     }6 li{7         float:Left ;8Margin-right:5px;;9 Ten     } One     #content{ Awidth:100%; -          -     } the</style> -<?PHP - //$dir = dirname (GETCWD ()); - //$filepath = $dir. ' \ \ '. ' Communication '. ' \\‘.‘ Mod_index.php '; + Header("content-type:text/html; Charset=utf-8 "); - $path=dirname(GETCWD()); + $direction=dir($path); A  at $allow=Array( -  - ); - $result=Array(); -Gettables ($direction); - $direction-close (); inPrintTable ($result); -  to  + /** - * Get the table name used by all PHP file query statements in this directory the * @param $direction directory control handle *  */ $ functionGettables ($direction){Panax Notoginseng     Global $allow,$result; -      while(($file=$direction->read ())! =false){ the         $tables=Array(); +         if($file! = '. ' &&$file! = '. ' &&Strpos($file,‘.‘) &&strstr($file,‘.‘) = = '. php '){ A             $filepath= GetPath ($direction->path,$file); the            $content=file_get_contents($filepath); +             Preg_match_all("/db_tablepre. [\ ' | '] ([^\s ' \ "]*)/I",$content,$tables); -             $tables=Array_unique($tables[1]); $             $result=Array_merge($result,$tables); $}ElseIf(Is_dir($childdir= GetPath ($direction->path,$file))){ -             if(In_array($file,$allow)){ -                 $dir=dir($childdir); theGettables ($dir); -                 $dir-close ();Wuyi}Else{ the                 Continue; -             } Wu         } -     } About } $  -  - /** Get Completion path - * @param $dir A * @param $file + * @return String the  */ - functionGetPath ($dir,$file){ $     return $dir.‘ \\‘.$file; the } the  the /** Print Form the * @param $arr -  */ in functionPrintTable ($arr){ the     $arr=Array_unique($arr); the     $html= ' <div id= ' content ><ul> '; About     $num= 0; the     foreach($arr  as $k){ the         $html. = "<li>$num:".$k. "</li>"; the         $num++; +     } -     $html. = ' </ul></div> '; the     Echo $html;Bayi     Echo"The number of <div style= ' Display:inherit ' > Data tables is:".Count($arr)." </div> "; the}

Use functions to query the names of all data tables used in the project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.