https://github.com/zeekinteractive/php-utils
Utility functions to help alleviate some common use cases.
https://github.com/zeekinteractive/php-utils
package php utilities
Last synced: about 2 months ago
JSON representation
Utility functions to help alleviate some common use cases.
- Host: GitHub
- URL: https://github.com/zeekinteractive/php-utils
- Owner: ZeekInteractive
- Created: 2018-02-28T16:08:02.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-11-22T12:23:12.000Z (over 5 years ago)
- Last Synced: 2025-04-05T14:36:30.476Z (2 months ago)
- Topics: package, php, utilities
- Language: PHP
- Homepage:
- Size: 75.2 KB
- Stars: 2
- Watchers: 15
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PHP Utils

## Purpose
Utility functions to help alleviate some common use cases.### Safe Read
```php
safe_read( $item, $key )
```Useful for accessing something without having to wrap it with `empty` or `isset` checks constantly.
Returns `false` if it's unable to find the item. Works with both objects and arrays.
### Is Constant True
```php
is_constant_true( $constant )
```Checks the following in order:
* Constant is defined
* Constant is `true`Helpful to avoid always having to check if the constant is defined before checking the value.
Returns either `true` or `false`.
### Get File
```php
get_file( $filename, $extension )
```Checks that the file exists and is readable.
Allowable file types are:
* xml
* sql
* txt
* jsonReturns the data of the file or `false` if it failed.
### Recursively Remove Directory
```php
rrmdir( $dir )
```Recursively delete a directory and all files and directories inside it.
This is useful because PHP's `rmdir` does not delete a directory if anything exists inside of it.
### Format Currency
Formats the given value with two decimal places, prefixed with a dollar sign.
```php
format_currency( 1.5 )
// $1.50
```