Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
class ExamplesController extends AppController {
public $fileCounts = array( );
public function countFilesByExtension( $fileExtension, $directoryPath ){
return $this->setFileCounts( $fileExtension, count( glob( "{$directory}*.{$fileExtension}" )));
public function setFileCounts( $key, $value = null ){
$this->fileCounts[ $key ] = $value;
public function generateFileCounts( array $fileExtensions, $directoryPath ){
foreach( $fileExtensions as $fileExtension ){
$this->countFilesByExtension( $fileExtension, $directoryPath );
public function index( ){
$extensions = array( 'jpg', 'gif', 'png' );
$this->generateFileCounts( $extensions, "../images/team/harry/" );
debug( $this->fileCounts );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.