Skip to content

Instantly share code, notes, and snippets.

@abbajbryant
Created November 15, 2012 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abbajbryant/4081086 to your computer and use it in GitHub Desktop.
Save abbajbryant/4081086 to your computer and use it in GitHub Desktop.
<?php
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