// this is some sample php code
$i = 0;
for ($i = 0; $i < 25; ++$i) {
echo $i;
}
# comment like this
function customFunction()
{
return mt_rand(1, 100);
}
while ($test) {
echo 'blah' . "\n";
};
$fruits = array('banana', 'strawberry', 'blueberry', 'apple', 'blackberry');
asort($fruits);
foreach ($fruits as $key => $value) {
echo $value;
}
<?php
namespace Sonic;
/**
* Util
*
* @category Sonic
* @package Util
* @author Craig Campbell
*/
class Util
{
/**
* deletes a directory recursively
*
* php's native rmdir() function only removes a directory if there is nothing in it
*
* @param string $path
* @return void
*/
public static function removeDir($path)
{
if (is_link($path)) {
return unlink($path);
}
$files = new \RecursiveDirectoryIterator($path);
foreach ($files as $file) {
if (in_array($file->getFilename(), array('.', '..'))) {
continue;
}
if ($file->isLink()) {
unlink($file->getPathName());
continue;
}
if ($file->isFile()) {
unlink($file->getRealPath());
continue;
}
if ($file->isDir()) {
self::removeDir($file->getRealPath());
}
}
return rmdir($path);
}
}