Home »
Imported messages »
comp.lang.php »
count() problem
count() problem [message #185705] |
Sat, 03 May 2014 18:18 |
Mr Oldies
Messages: 241 Registered: October 2013
Karma: 0
|
Senior Member |
|
|
$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.
|
|
|
|
|
|
|
Re: count() problem [message #185712 is a reply to message #185709] |
Sat, 03 May 2014 22:14 |
Denis McMahon
Messages: 634 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
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(at)gmail(dot)com
|
|
|
Goto Forum:
Current Time: Fri Jan 10 05:56:21 GMT 2025
Total time taken to generate the page: 0.10271 seconds