1. Go to this page and download the library: Download omnicode/php-util library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
omnicode / php-util example snippets
/**
* debug method from Cakephp - convenient wrapper for print_r
*
* @param $var
* @param bool|false $return
* @return string
*/
function dbg($var, $return = false)
/**
* checks if the given number is a natural number
*
* @param int|float|array $number
* @param bool $zero - if set to true zero will be considered
* @return bool
*/
function is_natural($number, $zero = false)
/**
* checks if the given value is between 2 values(inclusive)
*
* @param int $number
* @param int $min
* @param int $max
* @return bool
*/
function between($number, $min, $max)
/**
* if an array is provided checks the values of the array all to be numeric,
* if string is provided, will check to be comma separated list
*
* @param mixed $data - array of numbers or string as comma separated numbers
* @return bool
*/
function is_numeric_list($data)
/**
* create slug from string
*
* @param string $str
* @param string $symbol
* @return string - e.g. in word1-word2-word3 format
*/
function create_slug($str = "", $symbol = "-")
/**
* returns the first key of the array
*
* @param array $array
* @return mixed
*/
function get_first_key(array $array = [])
/**
* returns the first value of the array
*
* @param array $array
* @return mixed
*/
function get_first_value($array)
/**
* returns the last key of the array
*
* @param array $array
* @return mixed
*/
function get_last_key($array)
/**
* returns the last value of the array
*
* @param array $array
* @return mixed
*/
function get_last_value($array)
/**
* unsets array's items by value
*
* @param array $array - the original array
* @param array|string - the value or array of values to be unset
* @return array - the processed array
*/
function array_unset($array, $values = [])
/**
* returns the file name without the extension
*
* @param string $fileName
* @return string
*/
function get_file_name($fileName = '')
/**
* returns the file extension from full file name
*
* @param string $fileName
* @return string
*/
function get_file_extension($fileName)
/**
* if file exists will return it - with number concatenated
*
* @param $path
* @param $fileName
* @param int $n
* @return bool|string
*/
function check_file_exists($path, $fileName, $n = 100)
/**
* return timestamp from date considering "/" delimiter
*
* @return string
*/
function datetotime($date)
/**
* checks if the given date(s) are valid mysql dates
*
* @param null $date1
* @param null $date
* @return bool - true if all dates are valid, false otherwise
*/
function is_date($date1 = null, $date = null)
/**
* returns array with options for select box
*
* @param $min
* @param $max
* @param int $step
* @return array
*/
function get_range($min, $max, $step = 1)
/**
* @param $val
* @return string
*/
function _humanize($val)
/**
* returns constant of the class based on its value
*
* @param $className
* @param $value
* @param bool|true $humanize
* @return string
* @throws Exception
*/
function get_class_constant($className, $value, $humanize = true)
/**
* returns the list of constants of the given class
*
* @param $className
* @param bool|false $reverse
* @param bool|true $humanize
* @return array
* @throws Exception
*/
function get_class_constants($className, $reverse = false, $humanize = true)