/includes/skip/core/functions/collected.php

  1. <?php 
  2.  
  3. namespace skip\v1_0_0; 
  4.  
  5. /** 
  6. * skip_id() 
  7. * 
  8. * Getting an unique ID. 
  9. * 
  10. * @package Skip\Tools 
  11. * @since 1.0 
  12. * @ignore 
  13. */ 
  14. function id( $length = 5 ) { 
  15. return substr( md5( rand() * time() ), 0, $length ); 
  16.  
  17. /** 
  18. * skip_print( $value ) 
  19. * 
  20. * Printing out variables on HTML frontend 
  21. * 
  22. * @param mixed $value The value to print out 
  23. * @package Skip\Tools 
  24. * @since 1.0 
  25. * @ignore 
  26. */ 
  27. function p( $value ) { 
  28. echo '<pre>'; 
  29. print_r( $value ); 
  30. echo '</pre>'; 
  31. }  
  32.  
  33. /** 
  34. * skip_max_upload() 
  35. *  
  36. * Get the max upload size in Bytes 
  37. * 
  38. * @return int $size Returns the max upload size in Bytes 
  39. * @package Skip/Tools 
  40. * @since 1.0 
  41. */ 
  42. function max_upload() { 
  43. $size = ini_get( 'post_max_size' ); 
  44. $size = trim( $size ); 
  45. $last = strtolower( $size[strlen( $size )-1] ); 
  46.  
  47. switch( $last ) { 
  48. // The 'G' modifier is available since PHP 5.1.0 
  49. case 'g': 
  50. $size *= 1024; 
  51. case 'm': 
  52. $size *= 1024; 
  53. case 'k': 
  54. $size *= 1024; 
  55.  
  56. return $size; 
  57.  
  58. /** 
  59. * Marge arrays recursively and distinct 
  60. *  
  61. * Merges any number of arrays / parameters recursively, replacing  
  62. * entries with string keys with values from latter arrays.  
  63. * If the entry or the next value to be assigned is an array, then it  
  64. * automagically treats both arguments as an array. 
  65. * Numeric entries are appended, not replaced, but only if they are  
  66. * unique 
  67. * 
  68. * @param array $array1 Initial array to merge. 
  69. * @param array ... Variable list of arrays to recursively merge. 
  70. * 
  71. * @link http://www.php.net/manual/en/function.array-merge-recursive.php#96201 
  72. * @author Mark Roduner <mark.roduner@gmail.com> 
  73. * @ignore 
  74. */ 
  75. function array_merge_recursive_distinct() 
  76. $arrays = func_get_args(); 
  77. $base = array_shift($arrays); 
  78.  
  79. if(!is_array($base)) $base = empty($base) ? array() : array($base); 
  80.  
  81. foreach($arrays as $append) { 
  82. if(!is_array($append)) $append = array($append); 
  83. foreach($append as $key => $value) { 
  84. if(!array_key_exists($key, $base) and !is_numeric($key)) { 
  85. $base[$key] = $append[$key]; 
  86. continue; 
  87. if(is_array($value) or is_array($base[$key])) { 
  88. $base[$key] = skip_array_merge_recursive_distinct($base[$key], $append[$key]); 
  89. else if(is_numeric($key)) 
  90. if(!in_array($value, $base)) $base[] = $value; 
  91. else { 
  92. $base[$key] = $value; 
  93.  
  94. return $base; 
.