count number of entries in a directory ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bill Brother

    count number of entries in a directory ?

    is it possible to obtain the number of entries in a directory without
    enumerate it with opendir() function ?


  • Michael Fesser

    #2
    Re: count number of entries in a directory ?

    .oO(Bill Brother)
    [color=blue]
    >is it possible to obtain the number of entries in a directory without
    >enumerate it with opendir() function ?[/color]

    If PHP runs on a Linux box you can use a shell command:

    $dir = '/path/to/whatever';
    $count = `ls $dir | wc -l`;

    It might be necessary to adjust the parameters for the ls command.

    HTH
    Micha

    Comment

    • Andy Hassall

      #3
      Re: count number of entries in a directory ?

      On Wed, 25 Aug 2004 10:43:12 +0200, "Bill Brother" <bigbrother@ina me.com>
      wrote:
      [color=blue]
      >is it possible to obtain the number of entries in a directory without
      >enumerate it with opendir() function ?[/color]

      Why don't you want to use opendir()?

      --
      Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
      <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

      Comment

      • Chung Leong

        #4
        Re: count number of entries in a directory ?


        "Bill Brother" <bigbrother@ina me.com> wrote in message
        news:cghjf1$92r $1@news-reader5.wanadoo .fr...[color=blue]
        > is it possible to obtain the number of entries in a directory without
        > enumerate it with opendir() function ?
        >
        >[/color]

        count(glob($dir )) ?


        Comment

        Working...