Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #13213

Re: string length

From Tim Streater <timstreater@greenbee.net>
Newsgroups comp.lang.php
Subject Re: string length
Date 2014-03-18 17:47 +0000
Message-ID <180320141747086943%timstreater@greenbee.net> (permalink)
References <umgkqacqlbwl.1erkg4bj91fbo$.dlg@40tude.net> <MZZVu.45103$eg2.20462@fx25.am4> <lg9qie$i09$2@news.albasani.net>

Show all headers | View raw


In article <lg9qie$i09$2@news.albasani.net>, The Natural Philosopher
<tnp@invalid.invalid> wrote:

> Also keep in mind that '.' and '..' will appear in readdir() listings.
> 
>  From the readdir manual entry...
> 
> <?php
> if ($handle = opendir('.')) {
>      while (false !== ($entry = readdir($handle))) {
>          if ($entry != "." && $entry != "..") {
>              echo "$entry\n";
>          }
>      }
>      closedir($handle);
> }
> ?>

$dirh = opendir ($start);
if  ($dirh===false)
     {
     // handle error and return or exit
     }

while  (true)
     {

     $nextfile = readdir ($dirh);
     if  ($nextfile===false)  break;

     if  ($nextfile=='.' || $nextfile=='..')  continue;

     // Treat nextfile

     }


Much easier. Notice how the braces don't get more than one deep
(instead of three).

-- 
"People don't buy Microsoft for quality, they buy it for compatibility
with what Bob in accounting bought last year. Trace it back - they buy
Microsoft because the IBM Selectric didn't suck much" - P Seebach, afc

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

string length richard <noreply@example.com> - 2014-03-18 10:45 -0400
  Re: string length Tim Streater <timstreater@greenbee.net> - 2014-03-18 15:11 +0000
    Re: string length "Peter H. Coffin" <hellsop@ninehells.com> - 2014-03-18 10:39 -0500
    Re: string length The Natural Philosopher <tnp@invalid.invalid> - 2014-03-18 15:57 +0000
  Re: string length Gabe <usenet@moojuice.net> - 2014-03-18 15:53 +0000
    Re: string length The Natural Philosopher <tnp@invalid.invalid> - 2014-03-18 16:00 +0000
      Re: string length Tim Streater <timstreater@greenbee.net> - 2014-03-18 17:47 +0000
  Re: string length Denis McMahon <denismfmcmahon@gmail.com> - 2014-03-18 22:50 +0000

csiph-web