Download the PHP package mekramy/php-util without Composer
On this page you can find all versions of the php package mekramy/php-util. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mekramy/php-util
More information about mekramy/php-util
Files in mekramy/php-util
Informations about the package php-util
Helpers And Utility Functions For PHP
Quick Switch
If you need to check many conditions to set a variable value you can use quickSwitch
instead of deep ternary (?:), if/else or switch/case.
Quick switch simply accept a associative array of value => condition
. if any of conditions is truly or return truly value, returned as result otherwise the default value will returned.
Convert Date To Persian Date
You can pass string
date, DateTime
object, Carbon
instance or timestamp
to parse as persian date.
Note: If you pass null
as input date, this function return current date
Note If you pass null
as format parameter, this function return \Hekmatinasser\Verta\Verta
object instead of date string
.
Note If invalid date passed as input this function return null
Convert Persian Date To Date
You can pass string
persian date or \Hekmatinasser\Verta\Verta
instance to parse as gregorian date.
Note: If you pass null
as input date this function return current date
Note If you pass null
as format parameter this function return \Carbon\Carbon
object instead of date string
.
Note If invalid date passed as input this function return null
Validate Value
Check if value not empty and is a valid value (if allowed list passed) or return default value if not valid.
Note Pass null
as allowed values to ignore check
Validate Number
Check if value is a number and is in range (min/max) and is valid (allowed value) or return default.
Note If $float
set to true $value
parsed as float
otherwise parsed as int
Note Pass null
as allowed values to ignore check
Note Pass null
as min/max values to ignore check
Convert Value To Boolean
If value is 1
, "1"
, true
, "true"
, "on"
or "yes"
return true
otherwise return false
Extract Number From String
Format String With Placeholder
Print Debug Block
This function convert input variable to JSON pretty formatted and print to output using echo with headers and footer.
Note You can specify header text, separator character and header/footer length
All versions of php-util with dependencies
ext-json Version *
nesbot/carbon Version >=2.30
hekmatinasser/verta Version >=1.10