Created
November 15, 2012 20:33
-
-
Save abbajbryant/4081086 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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