pugboy Posted April 30, 2008 Share Posted April 30, 2008 On my site, I would like to have a live count of how many accounts were created. An account just consist of a folder with the files in it... I need to count how many folders are in the directory, so how would I do this? Quote Link to comment https://forums.phpfreaks.com/topic/103647-solved-counting-directories/ Share on other sites More sharing options...
hitman6003 Posted April 30, 2008 Share Posted April 30, 2008 Taken from the manual, with a very slight modification (http://www.php.net/class.dir): <?php $i = 0; $d = dir("/etc/php5"); echo "Handle: " . $d->handle . "\n"; echo "Path: " . $d->path . "\n"; while (false !== ($entry = $d->read())) { if (is_dir($entry)) { $i++; } } $d->close(); echo "Number of directories: " . $i; ?> Quote Link to comment https://forums.phpfreaks.com/topic/103647-solved-counting-directories/#findComment-530733 Share on other sites More sharing options...
pugboy Posted April 30, 2008 Author Share Posted April 30, 2008 Cool, thanks! Should have looked there first Uh oh... Errors Warning: is_dir() [function.is-dir]: open_basedir restriction in effect. File(..) is not within the allowed path(s): (/tmp:/var/tmp:/var/www/errors:/usr/share/php:/home/vol4/xxxx/flpsm_1828562/xxxxxx/htdocs) in /home/vol4/xxxxx/flpsm_1828562/xxxxx/htdocs/index.php on line 40 I put in the x's because I would like to keep the site private for now Quote Link to comment https://forums.phpfreaks.com/topic/103647-solved-counting-directories/#findComment-530737 Share on other sites More sharing options...
hitman6003 Posted April 30, 2008 Share Posted April 30, 2008 looks like php has safe mode turned on. Which means that unless the directory you're trying to read is one of those listed, you can't. Quote Link to comment https://forums.phpfreaks.com/topic/103647-solved-counting-directories/#findComment-530743 Share on other sites More sharing options...
pugboy Posted April 30, 2008 Author Share Posted April 30, 2008 Drat. I guess I will be moving hosts Quote Link to comment https://forums.phpfreaks.com/topic/103647-solved-counting-directories/#findComment-530744 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.