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


Groups > comp.lang.php > #13493 > unrolled thread

count() problem

Started byrichard <noreply@example.com>
First post2014-05-03 14:18 -0400
Last post2014-05-03 20:36 +0200
Articles 6 — 4 participants

Back to article view | Back to comp.lang.php


Contents

  count() problem richard <noreply@example.com> - 2014-05-03 14:18 -0400
    Re: count() problem "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2014-05-03 20:32 +0200
      Re: count() problem richard <noreply@example.com> - 2014-05-03 15:57 -0400
        Re: count() problem Denis McMahon <denismfmcmahon@gmail.com> - 2014-05-03 22:14 +0000
    Re: count() problem Richard Yates <richard@yatesguitar.com> - 2014-05-03 11:33 -0700
    Re: count() problem "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2014-05-03 20:36 +0200

#13493 — count() problem

Fromrichard <noreply@example.com>
Date2014-05-03 14:18 -0400
Subjectcount() problem
Message-ID<gpqyx6uagdlf$.10osd5vpnl4mw.dlg@40tude.net>
$dir    = '../audio/'.$yr.'/';
$files = scandir($dir);
$number=count(files);
echo $number;

Why does this always show the resutlt as 1?


$dir    = '../audio/'.$yr.'/';
$files = scandir($dir);
echo count(files);

Shows the true count of the array.

[toc] | [next] | [standalone]


#13494

From"M. Strobel" <sorry_no_mail_here@nowhere.dee>
Date2014-05-03 20:32 +0200
Message-ID<bskr2oFbovkU1@mid.uni-berlin.de>
In reply to#13493
Am 03.05.2014 20:18, schrieb richard:
> 
> $dir    = '../audio/'.$yr.'/';
> $files = scandir($dir);
> $number=count(files);
did you mean
   $number=count($files);
?
/Str.
> echo $number;
> 
> Why does this always show the resutlt as 1?
> 
> 
> $dir    = '../audio/'.$yr.'/';
> $files = scandir($dir);
> echo count(files);
> 
> Shows the true count of the array.
> 

[toc] | [prev] | [next] | [standalone]


#13497

Fromrichard <noreply@example.com>
Date2014-05-03 15:57 -0400
Message-ID<12gy39aq5y19e.1utiz5oozj29r$.dlg@40tude.net>
In reply to#13494
On Sat, 03 May 2014 20:32:56 +0200, M. Strobel wrote:

> Am 03.05.2014 20:18, schrieb richard:
>> 
>> $dir    = '../audio/'.$yr.'/';
>> $files = scandir($dir);
>> $number=count(files);
> did you mean
>    $number=count($files);
> ?
> /Str.
>> echo $number;
>> 
>> Why does this always show the resutlt as 1?
>> 
>> 
>> $dir    = '../audio/'.$yr.'/';
>> $files = scandir($dir);
>> echo count(files);
>> 
>> Shows the true count of the array.
>>

thanks. many times I overlook the obvious.

[toc] | [prev] | [next] | [standalone]


#13500

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2014-05-03 22:14 +0000
Message-ID<lk3po2$aom$3@dont-email.me>
In reply to#13497
On Sat, 03 May 2014 15:57:26 -0400, richard wrote:

> On Sat, 03 May 2014 20:32:56 +0200, M. Strobel wrote:
> 
>> Am 03.05.2014 20:18, schrieb richard:
>>> 
>>> $dir    = '../audio/'.$yr.'/';
>>> $files = scandir($dir); $number=count(files);
>> did you mean
>>    $number=count($files);
>> ?
>> /Str.
>>> echo $number;
>>> 
>>> Why does this always show the resutlt as 1?
>>> 
>>> 
>>> $dir    = '../audio/'.$yr.'/';
>>> $files = scandir($dir);
>>> echo count(files);
>>> 
>>> Shows the true count of the array.

> thanks. many times I overlook the obvious.

Did you even think to check for any warning messages? Did you have 
warnings turned on? PHP will usually generate a warning if warnings are 
on and you appear to have left a $ off of a variable name.

-- 
Denis McMahon, denismfmcmahon@gmail.com

[toc] | [prev] | [next] | [standalone]


#13495

FromRichard Yates <richard@yatesguitar.com>
Date2014-05-03 11:33 -0700
Message-ID<hhdam91713udd35qv9vt06k765dchinog1@4ax.com>
In reply to#13493
On Sat, 3 May 2014 14:18:22 -0400, richard <noreply@example.com>
wrote:

>
>$dir    = '../audio/'.$yr.'/';
>$files = scandir($dir);
>$number=count(files);
>echo $number;
>
>Why does this always show the resutlt as 1?

Because you left out a '$'

[toc] | [prev] | [next] | [standalone]


#13496

From"M. Strobel" <sorry_no_mail_here@nowhere.dee>
Date2014-05-03 20:36 +0200
Message-ID<bskr8uFbqvlU1@mid.uni-berlin.de>
In reply to#13493
Am 03.05.2014 20:18, schrieb richard:
> 
> $dir    = '../audio/'.$yr.'/';
> $files = scandir($dir);
> $number=count(files);
> echo $number;
> 
> Why does this always show the resutlt as 1?
> 
> 
> $dir    = '../audio/'.$yr.'/';
> $files = scandir($dir);
> echo count(files);
> 
> Shows the true count of the array.
> 
And you still have turned error reporting off. How often have you been told to turn
it on?

php > echo count(files), "\n";
PHP Notice:  Use of undefined constant files - assumed 'files' in php shell code on
line 1

Notice: Use of undefined constant files - assumed 'files' in php shell code on line 1
1
php >

/Str.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web