Jump to content

Search the Community

Showing results for tags 'php foreach glob'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 1 result

  1. Hi, Does any one know how to display a message instead of the warning error when there are no files in the folder you are doing a directory list of? I have the following code, which produces a list of files in the folder. The only problem is when the folder is empty. I get a foreach error only when there are no files in the folder. I can forsee that sometimes the folders will be empty so will want to show my own error instead of this server warning. I think the "GLOB_NOCHECK" function may help but this may actually only work with folders rather than files. The code that works when there are files in the folder but gives a PHP warning when there are no files in the folder: foreach (glob('../../_documents/*.*') as $file){ $fileName = basename($file); if ($fileName != 'index.php') {?> <li><?php echo"$fileName"?></li> <?php } //end if}//end foreach The warning error i get if there are no files in the folder: Warning: Invalid argument supplied for foreach() in..... I would like to put the following if there is nothing in the folder: <li>There are currently no files in this folder.</li>
×
×
  • Create New...