Download the PHP package hkp22/php-helpers without Composer
On this page you can find all versions of the php package hkp22/php-helpers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hkp22/php-helpers
More information about hkp22/php-helpers
Files in hkp22/php-helpers
Package php-helpers
Short Description Php Helpers inspired by Laravel Helpers for non-laravel projects.
License MIT
Informations about the package php-helpers
PHP Helper Functions extracted from Laravel
This project has extracted useful helper functions from laravel framework, which can be used outside Laravel.
Installation
You can install the package via composer:
Usage
- Arrays
- array_add()
- array_build()
- array_divide()
- array_dot()
- array_except()
- array_first()
- array_last()
- array_flatten()
- array_forget()
- array_get()
- array_set()
- array_has()
- array_only()
- array_pluck()
- array_pull()
- array_where()
- data_get()
- head()
- last()
- Strings
- camel_case()
- class_basename()
- e()
- ends_with()
- studly_case()
- Miscellaneous
- class_uses_recursive()
- dd()
- trait_uses_recursive()
- value()
Arrays
array_add()
The array_add
function adds a given key/value pair to an array if the given key doesn't already exist in the array:
array_build()
Build a new array using a callback.
array_divide()
The array_divide
function returns two arrays, one containing the keys, and the other containing the values of the given array:
array_dot()
The array_dot
function flattens a multi-dimensional array into a single level array that uses "dot" notation to indicate depth:
array_except()
The array_except
function removes the given key / value pairs from an array:
array_first()
The array_first
function returns the first element of an array passing a given truth test:
array_last()
The array_last
function returns the last element of an array passing a given truth test:
array_flatten()
The array_flatten
function flattens a multi-dimensional array into a single level array:
array_forget()
The array_forget
function removes a given key / value pair from a deeply nested array using "dot" notation:
array_get()
The array_get
function retrieves a value from a deeply nested array using "dot" notation:
array_set()
The array_set
function sets a value within a deeply nested array using "dot" notation:
array_has()
The array_has
function checks whether a given item or items exists in an array using "dot" notation:
array_only()
The array_only
function returns only the specified key / value pairs from the given array:
array_pluck()
The array_pluck
function retrieves all of the values for a given key from an array:
You may also specify how you wish the resulting list to be keyed:
array_pull()
The array_pull
function returns and removes a key / value pair from an array:
A default value may be passed as the third argument to the method. This value will be returned if the key doesn't exist:
array_where()
The array_where
function filters an array using the given Closure:
data_get()
The data_get
function retrieves a value from a nested array or object using "dot" notation:
head()
The head
function returns the first element in the given array:
last()
The last
function returns the last element in the given array:
Strings
camel_case()
The camel_case
function converts the given string to camelCase
:
class_basename()
The class_basename
returns the class name of the given class with the class' namespace removed:
e()
The e
function runs PHP's htmlspecialchars
function with the double_encode
option set to true
by default:
ends_with()
The ends_with
function determines if the given string ends with the given value:
studly_case()
The studly_case
function converts the given string to StudlyCase
:
Miscellaneous
class_uses_recursive()
The class_uses_recursive
function returns all traits used by a class, including traits used by all of its parent classes:
dd()
The dd
function dumps the given variables and ends execution of the script:
trait_uses_recursive()
The trait_uses_recursive
function returns all traits used by a trait:
value()
The value
function returns the value it is given. However, if you pass a Closure to the function, the Closure will be executed then its result will be returned: