Recent Pasties
Create a new one now.
Created on 25/01/2008 17:55 by Anonymous
function to_time($value){
// SQL Date
$datefields =
explode('-',
$value);
// Must be an English date
if (count($datefields) !=
3){ $datefields =
explode('/',
$value);
View complete code
function array_get($arr, $key, $default = false) {
return $arr[$key];
} else {
return $default;
}
}
View complete code
function human_bytes($a) {
$unim =
array('B',
'KB',
'MB',
'GB',
'TB',
'PB');
$c = 0;
while ($a>=1024) {
$c++;
$a = $a/1024;
}
View complete code
function ordinal($num) {
if ($num > 13 || $num < 11) {
case 1:
return $num.'st';
case 2:
return $num.'nd';
View complete code
function validate_extension
($filename,
$validExtensions =
array('zip',
'rar',
'jpg',
'jpeg',
'gif',
'bmp')) {
// find the last dot inside the filename
// if no dot was found, the extension is not valid
if (false === $dotPos) {
return false;
}
View complete code
<?php
function validate_extension
( $filename,
$validExtensions =
array() ){ // if no extensions given, use the default ones
if ( empty( $validExtensions ) ) { $validExtensions =
array('zip',
'rar',
'jpg',
'jpeg',
'gif',
'bmp');
}
View complete code
function validate_extension($file_name) {
$ext_array =
array(".zip",
".rar",
".jpg",
".jpeg",
".gif",
".bmp");
$ext_count =
count($ext_array);
if (!$file_name) {
View complete code