PHPEdit.net Community
   
1 2 3 4
Tutorials Tips Pasties Code Snippets
 

Home > Pasties

Recent Pasties

« < 1 - 2 > »

Create a new one now.

Created on 25/01/2008 17:55 by Anonymous

  1. function to_time($value){
  2.  
  3. // SQL Date
  4. $datefields = explode('-', $value);
  5.  
  6. // Must be an English date
  7. if (count($datefields) != 3){
  8. $datefields = explode('/', $value);
  9.  
View complete code

Created on 23/01/2008 23:13 by LetsSurf

  1. if (!function_exists('array_get')) {
  2. function array_get($arr, $key, $default = false) {
  3. if (array_key_exists($key, $arr)) {
  4. return $arr[$key];
  5. } else {
  6. return $default;
  7. }
  8. }
  9.  
View complete code

Created on 23/01/2008 23:13 by LetsSurf

  1. if (!function_exists('human_bytes')) {
  2. function human_bytes($a) {
  3. $unim = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
  4. $c = 0;
  5. while ($a>=1024) {
  6. $c++;
  7. $a = $a/1024;
  8. }
  9.  
View complete code

Created on 23/01/2008 23:12 by LetsSurf

  1. if (!function_exists('ordinal')) {
  2. function ordinal($num) {
  3. if ($num > 13 || $num < 11) {
  4. switch (substr($num, -1)) {
  5. case 1:
  6. return $num.'st';
  7. case 2:
  8. return $num.'nd';
  9.  
View complete code

Created on 23/01/2008 15:02 by Sebastien Hordeaux

  1. function validate_extension($filename, $validExtensions = array('zip',
    'rar', 'jpg', 'jpeg', 'gif', 'bmp'))
  2. {
  3. // find the last dot inside the filename
  4. $dotPos = strrpos($filename, '.');
  5. // if no dot was found, the extension is not valid
  6. if (false === $dotPos) {
  7. return false;
  8. }
  9.  
View complete code

Created on 23/01/2008 14:59 by Tobias Tom

  1. <?php
  2.  
  3. function validate_extension( $filename, $validExtensions = array() )
    {
  4. // if no extensions given, use the default ones
  5. if ( empty( $validExtensions ) ) {
  6. $validExtensions = array('zip', 'rar', 'jpg', 'jpeg', 'gif',
    'bmp');
  7. }
  8.  
  9.  
View complete code

Created on 17/01/2008 12:30 by Sebastien Hordeaux

  1. function validate_extension($file_name) {
  2.  
  3. $ext_array = array(".zip",".rar",".jpg",".jpeg",".gif",".bmp");
  4. $extension = strtolower(strrchr($file_name,"."));
  5. $ext_count = count($ext_array);
  6.  
  7.  
  8. if (!$file_name) {
  9.  
View complete code

 
PHPEdit User Community, © 2008 WaterProof SARL
Powered by PHPEdit