Documentation

functions.php

Table of Contents

Functions

app_date()  : string|null
Produce datetime string based on app timezone
str_slug()  : string
Convert the string into an SEO-friendly slug.
str_random()  : string
Generate a random string of a predefined length.
str_random_alpha()  : string
Generate a random alphabetical string of a predefined length.
str_random_num()  : string
Generate a random numeric string of a predefined length.
str_random_alphanum()  : string
Generate a random alphanumeric string of a predefined length.
str_from_camel()  : string
Convert a camelCase string using the $separator value passed
str_to_camel()  : string
Convert a camelCase string using the $separator value passed
str_title_case()  : string
Convert a string to title case
str_snake_case()  : string
Convert a string to snake case
str_kebab_case()  : string
Convert a string to snake case
array_collapse()  : array<string|int, mixed>
Collapse an array of arrays
array_flatten()  : array<string|int, mixed>
Flatten a multi-dimensional array
array_divide()  : array<string|int, mixed>
Divide the array in an array of keys and values
array_join()  : string
Join the array values into a string
array_prepend()  : array<string|int, mixed>
Prepend value to the array
array_pull()  : mixed
Pull value from the array and remove it
array_sort()  : array<string|int, mixed>
Sort array
array_sort_desc()  : array<string|int, mixed>
Sort array descending
array_ksort()  : array<string|int, mixed>
Sort array by keys
array_ksort_desc()  : array<string|int, mixed>
Sort array by keys, descending
array_usort()  : array<string|int, mixed>
Sort array by user-defined callback
array_uksort()  : array<string|int, mixed>
Sort array by user-defined callback using keys
array_make()  : array<string|int, mixed>
Force value to be any array (if it is not one already)

Functions

app_date()

Produce datetime string based on app timezone

app_date(string $format[, int|null $timestamp = null ][, string $env = 'APP_TIMEZONE' ][, mixed $envDefault = null ]) : string|null
Parameters
$format : string
$timestamp : int|null = null
$env : string = 'APP_TIMEZONE'
$envDefault : mixed = null
Return values
string|null

str_slug()

Convert the string into an SEO-friendly slug.

str_slug(string $string[, string $separator = '-' ]) : string
Parameters
$string : string
$separator : string = '-'
Return values
string

str_random()

Generate a random string of a predefined length.

str_random(int $length[, int $case = Str::MIXEDCASE ]) : string
Parameters
$length : int
$case : int = Str::MIXEDCASE
Return values
string

str_random_alpha()

Generate a random alphabetical string of a predefined length.

str_random_alpha(int $length[, int $case = Str::MIXEDCASE ]) : string
Parameters
$length : int
$case : int = Str::MIXEDCASE
Return values
string

str_random_num()

Generate a random numeric string of a predefined length.

str_random_num(int $length) : string
Parameters
$length : int
Return values
string

str_random_alphanum()

Generate a random alphanumeric string of a predefined length.

str_random_alphanum(int $length[, int $case = Str::MIXEDCASE ]) : string
Parameters
$length : int
$case : int = Str::MIXEDCASE
Return values
string

str_from_camel()

Convert a camelCase string using the $separator value passed

str_from_camel(string $string[, string|null $separator = '-' ][, bool $preserveCase = false ]) : string
Parameters
$string : string
$separator : string|null = '-'
$preserveCase : bool = false
Return values
string

str_to_camel()

Convert a camelCase string using the $separator value passed

str_to_camel(string $string) : string
Parameters
$string : string
Return values
string

str_title_case()

Convert a string to title case

str_title_case(string $string) : string
Parameters
$string : string
Return values
string

str_snake_case()

Convert a string to snake case

str_snake_case(string $string[, bool $preserveCase = false ]) : string
Parameters
$string : string
$preserveCase : bool = false
Return values
string

str_kebab_case()

Convert a string to snake case

str_kebab_case(string $string[, bool $preserveCase = false ]) : string
Parameters
$string : string
$preserveCase : bool = false
Return values
string

array_collapse()

Collapse an array of arrays

array_collapse(array<string|int, mixed>|AbstractArray $array) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>|AbstractArray
Return values
array<string|int, mixed>

array_flatten()

Flatten a multi-dimensional array

array_flatten(array<string|int, mixed>|AbstractArray $array[, int|float $depth = INF ]) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>|AbstractArray
$depth : int|float = INF
Return values
array<string|int, mixed>

array_divide()

Divide the array in an array of keys and values

array_divide(array<string|int, mixed>|AbstractArray $array) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>|AbstractArray
Return values
array<string|int, mixed>

array_join()

Join the array values into a string

array_join(array<string|int, mixed>|AbstractArray $array, string $glue[, string $finalGlue = '' ]) : string
Parameters
$array : array<string|int, mixed>|AbstractArray
$glue : string
$finalGlue : string = ''
Return values
string

array_prepend()

Prepend value to the array

array_prepend(array<string|int, mixed>|AbstractArray $array, mixed $value[, mixed $key = null ]) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>|AbstractArray
$value : mixed
$key : mixed = null
Return values
array<string|int, mixed>

array_pull()

Pull value from the array and remove it

array_pull(array<string|int, mixed> &$array, mixed $key) : mixed
Parameters
$array : array<string|int, mixed>
$key : mixed

array_sort()

Sort array

array_sort(array<string|int, mixed>|AbstractArray $array[, int $flags = SORT_REGULAR ][, bool $assoc = true ][, bool $descending = false ]) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>|AbstractArray
$flags : int = SORT_REGULAR
$assoc : bool = true
$descending : bool = false
Return values
array<string|int, mixed>

array_sort_desc()

Sort array descending

array_sort_desc(array<string|int, mixed>|AbstractArray $array[, int $flags = SORT_REGULAR ][, bool $assoc = true ]) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>|AbstractArray
$flags : int = SORT_REGULAR
$assoc : bool = true
Return values
array<string|int, mixed>

array_ksort()

Sort array by keys

array_ksort(array<string|int, mixed>|AbstractArray $array[, int $flags = SORT_REGULAR ][, bool $descending = false ]) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>|AbstractArray
$flags : int = SORT_REGULAR
$descending : bool = false
Return values
array<string|int, mixed>

array_ksort_desc()

Sort array by keys, descending

array_ksort_desc(array<string|int, mixed>|AbstractArray $array[, int $flags = SORT_REGULAR ]) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>|AbstractArray
$flags : int = SORT_REGULAR
Return values
array<string|int, mixed>

array_usort()

Sort array by user-defined callback

array_usort(array<string|int, mixed>|AbstractArray $array, mixed $callback[, bool $assoc = true ]) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>|AbstractArray
$callback : mixed
$assoc : bool = true
Return values
array<string|int, mixed>

array_uksort()

Sort array by user-defined callback using keys

array_uksort(array<string|int, mixed>|AbstractArray $array, mixed $callback) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>|AbstractArray
$callback : mixed
Return values
array<string|int, mixed>

array_make()

Force value to be any array (if it is not one already)

array_make(mixed $value) : array<string|int, mixed>
Parameters
$value : mixed
Return values
array<string|int, mixed>

        
On this page

Search results