Expression reference
Everything an expression can read and call. Expressions explains how to write one; this page is the list to look things up in.
An example gives the value after its arrow, written as JSON: "ABC" is the text ABC and [1,2] a list. Every example on this page is run by the platform’s own tests and returns the value shown.
Variables
Section titled “Variables”In a flow
Section titled “In a flow”Every expression in a node’s settings can read these.
| Variable | What it holds | Example |
|---|---|---|
$prev |
The output of the node wired into this one. | {{ $prev->order->id }} |
$start |
The data the run started with. A webhook flow has the request body under payload. | {{ $start->payload->email }} |
$workflow |
The run: another node’s output by name or id with node(), a received signal with signal(), the run id with runId(), and items() and pairedItem() for split runs. | {{ $workflow->node('Fetch order')->total }} |
$kv |
Key-value store entries, by key. | {{ $kv->lastCursor ?? '0' }} |
$secrets |
Secret values, by slug. They never appear in logs. | {{ $secrets->apiToken }} |
$signals |
Signals this run has received: get() one by event name, or all(). | {{ $signals->get('onApproval')?->payload?->approved }} |
$loop |
Inside @foreach only: index, iteration, count, remaining, first, last, even and odd. | @foreach ($prev->items as $item){{ $item }}@if (! $loop->last),@endif@endforeach |
$page |
Inside a Pager connector’s sub-flow only: index (from 0), startData and prevOutput. | {{ $page->index + 1 }} |
On a portal page or form
Section titled “On a portal page or form”A portal setting that takes an expression reads one variable, named for what the setting describes. Where you can write an expression lists which setting reads which.
| Variable | What it holds | Example |
|---|---|---|
$row |
A portal table’s row: the columns the page lists, by name. | {{ $row->klant }} · {{ $row->plaats }} |
$value |
A figure’s number, in its description and colour. | $value > 10 ? 'danger' : 'primary' |
$point |
A chart’s bar, slice or point: its label and value. | $point->value > 100 ? 'danger' : 'primary' |
$visitor |
The person a portal page or form is shown to: their name and email. | Hello {{ $visitor->name }} |
Directives
Section titled “Directives”Output a part only when a condition holds, with optional @elseif and @else, closed by @endif.
@if ($prev->total > 100)large @elseif ($prev->total > 10)medium @else small @endifWith $prev as {"total":50}, this gives "medium".
@foreach
Section titled “@foreach”Output a part once for each element of a list or object, closed by @endforeach. $loop describes the iteration.
@foreach ($prev->tags as $tag)[{{ $tag }}]@endforeachWith $prev as {"tags":["a","b"]}, this gives "[a][b]".
A JSON document, closed by @endjson, in which a string that is a path such as “$.prev.id” is replaced by the value it reads, keeping its type. @json($prev) makes the paths relative to $prev.
@json($prev){"id": "$.id", "currency": "EUR"}@endjsonWith $prev as {"id":7}, this gives the JSON {"id":7,"currency":"EUR"}.
Assignments, if, foreach and switch over several lines, closed by @endphp. It outputs nothing; the variables it sets can be used after it.
@php $total = array_sum($prev->amounts); @endphp{{ $total }}With $prev as {"amounts":[1,2,3]}, this gives "6".
Operators
Section titled “Operators”Beyond arithmetic and comparison, these are the operators expressions use most. Each example reads $prev, so its result is given for the $prev shown.
| Operator | What it does | Example | Gives |
|---|---|---|---|
?? |
The left value, or the right one when the left is null or absent. | $prev->nickname ?? 'anonymous' |
"anonymous", when $prev is {"name":"Ada"} |
?-> |
Read a property, or get null instead of an error when the value before it is null. | $prev->address?->city |
null, when $prev is {"address":null} |
? : |
One of two values by a condition. | $prev->paid ? 'paid' : 'open' |
"open", when $prev is {"paid":false} |
|> |
Pass the value on the left as the first argument of the call on the right. | $prev->email |> trim() |> strtolower() |
"ada@example.com", when $prev is {"email":" Ada@Example.com "} |
match |
The value of the first arm whose condition is equal to the subject; default when none is. | match ($prev->status) { 'paid' => 'green', 'late' => 'red', default => 'gray' } |
"red", when $prev is {"status":"late"} |
fn () => |
A short callback, for functions such as array_map() and array_filter(). | array_map(fn ($line) => $line->qty, $prev->lines) |
[2,5], when $prev is {"lines":[{"qty":2},{"qty":5}]} |
(int) (float) (string) (bool) (array) |
Convert a value to another type. | (int) $prev->quantity |
12, when $prev is {"quantity":"12"} |
. |
Join two strings. | $prev->first . ' ' . $prev->last |
"Ada Lovelace", when $prev is {"first":"Ada","last":"Lovelace"} |
isset() empty() |
Whether a value is set and not null; whether it is absent or falsy. | isset($prev->discount) |
false, when $prev is {"total":10} |
&& || ! xor |
And, or, not, and exactly one of two. | $prev->paid && ! $prev->shipped |
true, when $prev is {"paid":true,"shipped":false} |
== === != !== < <= > >= |
Compare. === and !== also compare the type, so “5” === 5 is false. | $prev->count >= 10 |
true, when $prev is {"count":12} |
+ - * / % |
Arithmetic. % is the remainder of a whole-number division. | $prev->price * $prev->qty |
10.0, when $prev is {"price":2.5,"qty":4} |
Functions
Section titled “Functions”Call these by name, as you would in PHP. Nothing outside this list can be called.
Arrays
Section titled “Arrays”| Function | What it does | Example |
|---|---|---|
array_chunk(array $array, int $length, bool $preserve_keys = false): array |
Split an array into chunks of the given size. | array_chunk([1, 2, 3, 4, 5], 2) → [[1,2],[3,4],[5]] |
array_column(array $array, int|string|null $column_key, int|string|null $index_key = null): array |
Take one column from a list of rows, optionally keyed by another column. | array_column([['id' => 1, 'name' => 'Ada'], ['id' => 2, 'name' => 'Bo']], 'name', 'id') → {"1":"Ada","2":"Bo"} |
array_combine(array $keys, array $values): array |
Build an array from a list of keys and a list of values of the same length. | array_combine(['a', 'b'], [1, 2]) → {"a":1,"b":2} |
array_count_values(array $array): array |
Count how often each value occurs. | array_count_values(['nl', 'be', 'nl']) → {"nl":2,"be":1} |
array_diff(array $array, array ...$arrays): array |
The values of the first array that appear in none of the others. Keys are kept. | array_diff([1, 2, 3, 4], [2, 4]) → {"0":1,"2":3} |
array_diff_assoc(array $array, array ...$arrays): array |
The entries of the first array whose key and value together appear in none of the others. | array_diff_assoc(['a' => 1, 'b' => 2], ['a' => 1, 'b' => 3]) → {"b":2} |
array_diff_key(array $array, array ...$arrays): array |
The entries of the first array whose keys appear in none of the others. | array_diff_key(['a' => 1, 'b' => 2], ['a' => 0]) → {"b":2} |
array_fill(int $start_index, int $count, mixed $value): array |
An array of the same value repeated, starting at the given index. | array_fill(0, 3, 'x') → ["x","x","x"] |
array_fill_keys(array $keys, mixed $value): array |
An array with the given keys, each set to the same value. | array_fill_keys(['a', 'b'], 0) → {"a":0,"b":0} |
array_filter(array $array, ?callable $callback = null, int $mode = 0): array |
Keep the elements a callback returns true for, or the truthy ones without a callback. Keys are kept; wrap it in array_values() for a list. | array_filter([3, 8, 12], fn ($n) => $n > 5) → {"1":8,"2":12} |
array_flip(array $array): array |
Swap keys and values. | array_flip(['a' => 1, 'b' => 2]) → {"1":"a","2":"b"} |
array_intersect(array $array, array ...$arrays): array |
The values of the first array that appear in every other one. Keys are kept. | array_intersect(['nl', 'be', 'de'], ['de', 'nl']) → {"0":"nl","2":"de"} |
array_intersect_assoc(array $array, array ...$arrays): array |
The entries of the first array whose key and value together appear in every other one. | array_intersect_assoc(['a' => 1, 'b' => 2], ['a' => 1, 'b' => 3]) → {"a":1} |
array_intersect_key(array $array, array ...$arrays): array |
The entries of the first array whose keys appear in every other one. | array_intersect_key(['a' => 1, 'b' => 2, 'c' => 3], ['a' => 0, 'c' => 0]) → {"a":1,"c":3} |
array_is_list(array $array): bool |
Whether the keys are 0, 1, 2 and so on, in order. | array_is_list([1, 2]) → true |
array_key_exists($key, array $array): bool |
Whether the array has the key, even when its value is null. | array_key_exists('b', ['a' => 1, 'b' => null]) → true |
array_key_first(array $array): string|int|null |
The first key. | array_key_first(['x' => 1, 'y' => 2]) → "x" |
array_key_last(array $array): string|int|null |
The last key. | array_key_last(['x' => 1, 'y' => 2]) → "y" |
array_keys(array $array, mixed $filter_value = null): array |
All keys, as a list. | array_keys(['a' => 1, 'b' => 2]) → ["a","b"] |
array_map(?callable $callback, array $array, array ...$arrays): array |
Apply a callback to every element and return the results. | array_map(fn ($n) => $n * 2, [1, 2, 3]) → [2,4,6] |
array_merge(array ...$arrays): array |
Join arrays: list values are appended, and a later string key replaces an earlier one. | array_merge(['a' => 1, 'b' => 2], ['b' => 3]) → {"a":1,"b":3} |
array_merge_recursive(array ...$arrays): array |
Join arrays, merging the values of equal string keys into lists. | array_merge_recursive(['tags' => ['a']], ['tags' => ['b']]) → {"tags":["a","b"]} |
array_pad(array $array, int $length, mixed $value): array |
Pad an array to a length with a value. | array_pad([1, 2], 4, 0) → [1,2,0,0] |
array_pop(array &$array): mixed |
Remove the last element of an array held in a variable, and return it. | @php $list = [1, 2, 3]; $last = array_pop($list); @endphp{{ $last }}, leaving {{ count($list) }} → "3, leaving 2" |
array_product(array $array): int|float |
Multiply all values. | array_product([2, 3, 4]) → 24 |
array_push(array &$array, mixed ...$values): int |
Add values to the end of an array held in a variable; returns the new length. | @php $list = [1, 2]; $length = array_push($list, 3); @endphp{{ implode(',', $list) }} → "1,2,3" |
array_replace(array $array, array ...$replacements): array |
Replace values by key with those of the later arrays. | array_replace(['a' => 1, 'b' => 2], ['b' => 3]) → {"a":1,"b":3} |
array_reverse(array $array, bool $preserve_keys = false): array |
The elements in reverse order. | array_reverse([1, 2, 3]) → [3,2,1] |
array_search(mixed $needle, array $haystack, bool $strict = false): int|string|false |
The key of the first element equal to a value, or false. | array_search('be', ['nl', 'be']) → 1 |
array_shift(array &$array): mixed |
Remove the first element of an array held in a variable, and return it. | @php $list = [1, 2, 3]; $first = array_shift($list); @endphp{{ $first }} → "1" |
array_slice(array $array, int $offset, ?int $length = null, bool $preserve_keys = false): array |
A part of an array, from an offset, optionally for a length. | array_slice([1, 2, 3, 4], 1, 2) → [2,3] |
array_splice(array &$array, int $offset, ?int $length = null, mixed $replacement = []): array |
Remove a part of an array held in a variable, optionally putting other values in its place; returns what was removed. | @php $list = [1, 2, 3, 4]; $removed = array_splice($list, 1, 2); @endphp{{ implode(',', $list) }} → "1,4" |
array_sum(array $array): int|float |
Add up all values. | array_sum([1, 2, 3.5]) → 6.5 |
array_unique(array $array, int $flags = SORT_STRING): array |
Drop repeated values, keeping the first of each. Keys are kept. | array_unique(['a', 'b', 'a']) → ["a","b"] |
array_unshift(array &$array, mixed ...$values): int |
Add values to the start of an array held in a variable; returns the new length. | @php $list = [2, 3]; $length = array_unshift($list, 1); @endphp{{ implode(',', $list) }} → "1,2,3" |
array_values(array $array): array |
All values, re-numbered from 0. | array_values(['a' => 1, 'b' => 2]) → [1,2] |
array_walk(array|object &$array, callable $callback, mixed $arg = null): true |
Call a callback with every element and its key. The callback cannot change the array here, so array_map() is usually what you want. | |
count(Countable|array $array): int |
The number of elements. | count([1, 2, 3]) → 3 |
in_array(mixed $needle, array $haystack, bool $strict = false): bool |
Whether a value is in the array. | in_array('be', ['nl', 'be']) → true |
krsort(array &$array, int $flags = 0): true |
Sort an array held in a variable by key, high to low. | @php $map = ['a' => 1, 'b' => 2]; $sorted = krsort($map); @endphp{{ implode(',', array_keys($map)) }} → "b,a" |
ksort(array &$array, int $flags = 0): true |
Sort an array held in a variable by key, low to high. | @php $map = ['b' => 2, 'a' => 1]; $sorted = ksort($map); @endphp{{ implode(',', array_keys($map)) }} → "a,b" |
range(string|int|float $start, string|int|float $end, int|float $step = 1): array |
A list of numbers or letters from start to end, optionally in steps. | range(0, 10, 5) → [0,5,10] |
rsort(array &$array, int $flags = 0): true |
Sort an array held in a variable by value, high to low, re-numbering it. | @php $list = [3, 1, 2]; $sorted = rsort($list); @endphp{{ implode(',', $list) }} → "3,2,1" |
shuffle(array &$array): true |
Put an array held in a variable in random order. | |
sort(array &$array, int $flags = SORT_REGULAR): true |
Sort an array held in a variable by value, low to high, re-numbering it. | @php $list = [3, 1, 2]; $sorted = sort($list); @endphp{{ implode(',', $list) }} → "1,2,3" |
uasort(array &$array, callable $callback): true |
Sort an array held in a variable with a comparison callback, keeping its keys. | @php $map = ['a' => 3, 'b' => 1]; $sorted = uasort($map, fn ($x, $y) => $x - $y); @endphp{{ implode(',', array_keys($map)) }} → "b,a" |
uksort(array &$array, callable $callback): true |
Sort an array held in a variable by key with a comparison callback. | @php $map = ['bb' => 1, 'a' => 2]; $sorted = uksort($map, fn ($x, $y) => strlen($x) - strlen($y)); @endphp{{ implode(',', array_keys($map)) }} → "a,bb" |
usort(array &$array, callable $callback): true |
Sort an array held in a variable with a comparison callback that returns a negative number, zero or a positive number. | @php $list = [3, 1, 2]; $sorted = usort($list, fn ($a, $b) => $a - $b); @endphp{{ implode(',', $list) }} → "1,2,3" |
Strings
Section titled “Strings”| Function | What it does | Example |
|---|---|---|
bin2hex(string $string): string |
The hexadecimal form of each byte. | bin2hex('abc') → "616263" |
chr(int $codepoint): string |
The character with the given byte value. | chr(65) → "A" |
chunk_split(string $string, int $length = 76, string $separator = "\r\n"): string |
Insert a separator after every chunk of the given length. | chunk_split('abcdef', 2, '-') → "ab-cd-ef-" |
explode(string $separator, string $string, int $limit = PHP_INT_MAX): array |
Split a string on a separator. | explode(',', 'a,b,c') → ["a","b","c"] |
hex2bin(string $string): string|false |
Turn hexadecimal back into bytes. | hex2bin('616263') → "abc" |
html_entity_decode(string $string, int $flags = 11, ?string $encoding = null): string |
Turn HTML entities back into characters. | html_entity_decode('Tom & Jerry') → "Tom & Jerry" |
htmlentities(string $string, int $flags = 11, ?string $encoding = null, bool $double_encode = true): string |
Turn every character that has an HTML entity into it. | htmlentities('café & co') → "café & co" |
htmlspecialchars(string $string, int $flags = 11, ?string $encoding = null, bool $double_encode = true): string |
Escape the characters HTML treats specially: ampersand, quotes, less-than and greater-than. | htmlspecialchars('<b>') → "<b>" |
htmlspecialchars_decode(string $string, int $flags = 11): string |
Undo htmlspecialchars(). | htmlspecialchars_decode('<b>') → "<b>" |
implode(string $separator, array $array): string |
Join a list into a string with a separator. | implode(', ', ['a', 'b']) → "a, b" |
join(array|string $separator, ?array $array = null): string |
Another name for implode(). | join('-', ['a', 'b']) → "a-b" |
lcfirst(string $string): string |
Make the first character lowercase. | lcfirst('Hello') → "hello" |
ltrim(string $string, string $characters = " \n\r\t\v\000"): string |
Strip whitespace, or the given characters, from the start. | ltrim('0042', '0') → "42" |
mb_convert_encoding(array|string $string, string $to_encoding, array|string|null $from_encoding = null): array|string|false |
Convert a string from one character encoding to another. | |
mb_detect_encoding(string $string, array|string|null $encodings = null, bool $strict = false): string|false |
Guess the character encoding of a string. | mb_detect_encoding('café') → "UTF-8" |
mb_lcfirst(string $string, ?string $encoding = null): string |
Make the first character lowercase, accents included. | mb_lcfirst('Élan') → "élan" |
mb_ltrim(string $string, ?string $characters = null, ?string $encoding = null): string |
Strip whitespace, or the given characters, from the start, Unicode-aware. | mb_ltrim(' café') → "café" |
mb_rtrim(string $string, ?string $characters = null, ?string $encoding = null): string |
Strip whitespace, or the given characters, from the end, Unicode-aware. | mb_rtrim('café ') → "café" |
mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = STR_PAD_RIGHT, ?string $encoding = null): string |
Pad a string to a length in characters. The fourth argument is 1 to pad the end (the default), 0 the start, 2 both sides. | mb_str_pad('é', 3, '-') → "é--" |
mb_str_split(string $string, int $length = 1, ?string $encoding = null): array |
Split a string into characters, or chunks of characters. | mb_str_split('café') → ["c","a","f","é"] |
mb_strlen(string $string, ?string $encoding = null): int |
The length in characters. | mb_strlen('café') → 4 |
mb_strpos(string $haystack, string $needle, int $offset = 0, ?string $encoding = null): int|false |
The character position of the first occurrence, or false. | mb_strpos('café au lait', 'au') → 5 |
mb_strrpos(string $haystack, string $needle, int $offset = 0, ?string $encoding = null): int|false |
The character position of the last occurrence, or false. | mb_strrpos('a-b-c', '-') → 3 |
mb_strtolower(string $string, ?string $encoding = null): string |
Lowercase, accents included. | mb_strtolower('ÉCOLE') → "école" |
mb_strtoupper(string $string, ?string $encoding = null): string |
Uppercase, accents included. | mb_strtoupper('école') → "ÉCOLE" |
mb_substr(string $string, int $start, ?int $length = null, ?string $encoding = null): string |
Part of a string, counted in characters. | mb_substr('café au lait', 0, 4) → "café" |
mb_trim(string $string, ?string $characters = null, ?string $encoding = null): string |
Strip whitespace, or the given characters, from both ends, Unicode-aware. | mb_trim(' café ') → "café" |
mb_ucfirst(string $string, ?string $encoding = null): string |
Make the first character uppercase, accents included. | mb_ucfirst('élan') → "Élan" |
nl2br(string $string, bool $use_xhtml = true): string |
Put an HTML line break before every newline. | nl2br("a\nb") → "a<br />\nb" |
number_format(float $num, int $decimals = 0, string $decimal_separator = ".", string $thousands_separator = ","): string |
Format a number with decimals and separators. | number_format(1234.567, 2, ',', '.') → "1.234,57" |
ord(string $character): int |
The byte value of the first character. | ord('A') → 65 |
preg_match(string $pattern, string $subject, array &$matches = null, int $flags = 0): int|false |
1 when a regular expression matches, 0 when it does not. | preg_match('/^\d{4}$/', '2026') → 1 |
preg_match_all(string $pattern, string $subject, array &$matches = null, int $flags = 0, int $offset = 0): int|false |
How many times a regular expression matches. | preg_match_all('/\d/', 'a1b2c3') → 3 |
preg_replace(string|array $pattern, string|array $replacement, string|array $subject): string|array|null |
Replace what a regular expression matches. | preg_replace('/\s+/', ' ', 'a b') → "a b" |
preg_split(string $pattern, string $subject, int $limit = -1, int $flags = 0): array|false |
Split a string where a regular expression matches. | preg_split('/[,;]\s*/', 'a, b;c') → ["a","b","c"] |
rawurldecode(string $string): string |
Decode a percent-encoded string (RFC 3986). | rawurldecode('a%20b') → "a b" |
rawurlencode(string $string): string |
Percent-encode a string for a URL path (RFC 3986): a space becomes %20. | rawurlencode('a b') → "a%20b" |
rtrim(string $string, string $characters = " \n\r\t\v\000"): string |
Strip whitespace, or the given characters, from the end. | rtrim('1.500', '0') → "1.5" |
sprintf(string $format, mixed ...$values): string |
Fill placeholders such as %s (text) and %d (whole number) into a format. | sprintf('%s has %d items', 'Cart', 3) → "Cart has 3 items" |
str_contains(string $haystack, string $needle): bool |
Whether a string contains another, case-sensitive. | str_contains('Publicus', 'lic') → true |
str_ends_with(string $haystack, string $needle): bool |
Whether a string ends with another. | str_ends_with('invoice.pdf', '.pdf') → true |
str_ireplace(array|string $search, array|string $replace, array|string $subject, &$count = null): array|string |
Replace text, ignoring case. | str_ireplace('WORLD', 'there', 'Hello world') → "Hello there" |
str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = STR_PAD_RIGHT): string |
Pad a string to a length. The fourth argument is 1 to pad the end (the default), 0 the start, 2 both sides. | str_pad('7', 3, '0', 0) → "007" |
str_repeat(string $string, int $times): string |
Repeat a string. | str_repeat('ab', 3) → "ababab" |
str_replace(array|string $search, array|string $replace, string|array $subject): string|array |
Replace every occurrence of some text. | str_replace('-', ' ', 'a-b-c') → "a b c" |
str_split(string $string, int $length = 1): array |
Split a string into chunks of bytes. | str_split('abcdef', 2) → ["ab","cd","ef"] |
str_starts_with(string $haystack, string $needle): bool |
Whether a string starts with another. | str_starts_with('INV-001', 'INV-') → true |
str_word_count(string $string, int $format = 0, ?string $characters = null): array|int |
The number of words. | str_word_count('the quick brown fox') → 4 |
strip_tags(string $string, array|string|null $allowed_tags = null): string |
Remove HTML tags. | strip_tags('<p>Hello <b>you</b></p>') → "Hello you" |
stripos(string $haystack, string $needle, int $offset = 0): int|false |
The position of the first occurrence ignoring case, or false. | stripos('Hello', 'L') → 2 |
strlen(string $string): int |
The length in bytes; an accented letter counts twice. Use mb_strlen() for characters. | strlen('café') → 5 |
strpos(string $haystack, string $needle, int $offset = 0): int|false |
The byte position of the first occurrence, or false. | strpos('a-b-c', '-') → 1 |
strrchr(string $haystack, string $needle, bool $before_needle = false): string|false |
The rest of a string from the last occurrence of a character. | strrchr('a/b/c', '/') → "/c" |
strrev(string $string): string |
Reverse a string. | strrev('abc') → "cba" |
strrpos(string $haystack, string $needle, int $offset = 0): int|false |
The byte position of the last occurrence, or false. | strrpos('a-b-c', '-') → 3 |
strstr(string $haystack, string $needle, bool $before_needle = false): string|false |
The rest of a string from the first occurrence of another. | strstr('user@example.com', '@') → "@example.com" |
strtolower(string $string): string |
Lowercase (ASCII letters only; use mb_strtolower() for accents). | strtolower('ABC') → "abc" |
strtoupper(string $string): string |
Uppercase (ASCII letters only; use mb_strtoupper() for accents). | strtoupper('abc') → "ABC" |
strval(mixed $value): string |
The value as a string. | strval(42) → "42" |
substr(string $string, int $offset, ?int $length = null): string |
Part of a string, counted in bytes. | substr('Publicus', 0, 3) → "Pub" |
substr_count(string $haystack, string $needle, int $offset = 0, ?int $length = null): int |
How often some text occurs. | substr_count('a,b,c', ',') → 2 |
substr_replace(array|string $string, array|string $replace, array|int $offset, array|int|null $length = null): array|string |
Replace part of a string by position. | substr_replace('2026-10-24', '01', 8, 2) → "2026-10-01" |
trim(string $string, string $characters = " \t\n\r\0\x0B"): string |
Strip whitespace, or the given characters, from both ends. | trim(' hi ') → "hi" |
ucfirst(string $string): string |
Make the first character uppercase. | ucfirst('hello') → "Hello" |
ucwords(string $string, string $separators = " \t\r\n\f\v"): string |
Make the first character of every word uppercase. | ucwords('hello world') → "Hello World" |
urldecode(string $string): string |
Decode a query-string value: a plus becomes a space. | urldecode('a+b%26c') → "a b&c" |
urlencode(string $string): string |
Encode a query-string value: a space becomes a plus. | urlencode('a b&c') → "a+b%26c" |
wordwrap(string $string, int $width = 75, string $break = "\n", bool $cut_long_words = false): string |
Wrap text at a width with a line break. | wordwrap('The quick brown fox', 10, '|', true) → "The quick|brown fox" |
| Function | What it does | Example |
|---|---|---|
abs(int|float $num): int|float |
The absolute value. | abs(-4.5) → 4.5 |
ceil(int|float $num): float |
Round up to a whole number. | ceil(4.1) → 5.0 |
exp(float $num): float |
e raised to a power. | exp(0) → 1.0 |
floor(int|float $num): float |
Round down to a whole number. | floor(4.9) → 4.0 |
fmod(float $num1, float $num2): float |
The remainder of a division, for decimals. | fmod(10, 3) → 1.0 |
intdiv(int $num1, int $num2): int |
Whole-number division. | intdiv(10, 3) → 3 |
log(float $num, float $base = M_E): float |
The natural logarithm, or the logarithm in the given base. | log(8, 2) → 3.0 |
log10(float $num): float |
The base-10 logarithm. | log10(1000) → 3.0 |
max(mixed $value, mixed ...$values): mixed |
The highest of the arguments, or of one array. | max([3, 7, 5]) → 7 |
min(mixed $value, mixed ...$values): mixed |
The lowest of the arguments, or of one array. | min(3, 7, 5) → 3 |
pi(): float |
The number pi. | round(pi(), 2) → 3.14 |
pow(mixed $base, mixed $exp): int|float |
A number raised to a power. | pow(2, 10) → 1024 |
round(int|float $num, int $precision = 0, int $mode = PHP_ROUND_HALF_UP): float |
Round to a number of decimals, halves away from zero. | round(2.675, 2) → 2.68 |
sqrt(float $num): float |
The square root. | sqrt(16) → 4.0 |
| Function | What it does | Example |
|---|---|---|
boolval(mixed $value): bool |
The value as true or false. | boolval('0') → false |
ctype_alnum(mixed $text): bool |
Whether every character is a letter or digit. | ctype_alnum('abc123') → true |
ctype_alpha(mixed $text): bool |
Whether every character is a letter. | ctype_alpha('abc') → true |
ctype_digit(mixed $text): bool |
Whether every character is a digit. Pass a string: a number is read as a character code. | ctype_digit('2026') → true |
ctype_lower(mixed $text): bool |
Whether every character is a lowercase letter. | ctype_lower('abc') → true |
ctype_punct(mixed $text): bool |
Whether every character is punctuation. | ctype_punct('!?') → true |
ctype_space(mixed $text): bool |
Whether every character is whitespace. | ctype_space(' ') → true |
ctype_upper(mixed $text): bool |
Whether every character is an uppercase letter. | ctype_upper('ABC') → true |
ctype_xdigit(mixed $text): bool |
Whether every character is a hexadecimal digit. | ctype_xdigit('ff00') → true |
doubleval(mixed $value): float |
Another name for floatval(). | doubleval('1.5') → 1.5 |
floatval(mixed $value): float |
The value as a decimal number, read from the start of a string. | floatval('1.5kg') → 1.5 |
gettype(mixed $value): string |
The value’s type: boolean, integer, double, string, array, object or NULL. | gettype(1.5) → "double" |
intval(mixed $value, int $base = 10): int |
The value as a whole number, read from the start of a string. | intval('42abc') → 42 |
is_array(mixed $value): bool |
Whether the value is an array. | is_array([1]) → true |
is_bool(mixed $value): bool |
Whether the value is true or false. | is_bool(false) → true |
is_countable(mixed $value): bool |
Whether count() can be called on the value. | is_countable([1]) → true |
is_double(mixed $value): bool |
Another name for is_float(). | is_double(1.5) → true |
is_float(mixed $value): bool |
Whether the value is a decimal number. | is_float(1.5) → true |
is_int(mixed $value): bool |
Whether the value is a whole number. A numeric string is not. | is_int('5') → false |
is_integer(mixed $value): bool |
Another name for is_int(). | is_integer(5) → true |
is_iterable(mixed $value): bool |
Whether @foreach can loop over the value. | is_iterable([1]) → true |
is_long(mixed $value): bool |
Another name for is_int(). | is_long(5) → true |
is_null(mixed $value): bool |
Whether the value is null. | is_null(null) → true |
is_numeric(mixed $value): bool |
Whether the value is a number or a string holding one. | is_numeric('12.5') → true |
is_object(mixed $value): bool |
Whether the value is an object, such as a JSON object from another node. | is_object([]) → false |
is_scalar(mixed $value): bool |
Whether the value is a string, number or boolean. | is_scalar('a') → true |
is_string(mixed $value): bool |
Whether the value is a string. | is_string(5) → false |
Encoding and hashing
Section titled “Encoding and hashing”| Function | What it does | Example |
|---|---|---|
base64_decode(string $string, bool $strict = false): string|false |
Decode base64. | base64_decode('aGVsbG8=') → "hello" |
base64_encode(string $string): string |
Encode as base64. | base64_encode('hello') → "aGVsbG8=" |
crc32(string $string): int |
The CRC32 checksum, as a number. | crc32('hello') → 907060870 |
hash(string $algo, string $data, bool $binary = false, array $options = []): string |
A hash with the named algorithm, such as sha256, as hexadecimal. | hash('sha256', 'abc') → "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" |
hash_hmac(string $algo, string $data, string $key, bool $binary = false): string |
A keyed hash (HMAC) with the named algorithm, as hexadecimal; what most webhook signatures are. | hash_hmac('sha256', 'message', 'secret') → "8b5f48702995c1598c573db1e21866a9b825d4a794d169d7060a03605796360b" |
md5(string $string, bool $binary = false): string |
The MD5 hash, as hexadecimal. Not for anything secret. | md5('hello') → "5d41402abc4b2a76b9719d911017c592" |
sha1(string $string, bool $binary = false): string |
The SHA-1 hash, as hexadecimal. | sha1('hello') → "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d" |
| Function | What it does | Example |
|---|---|---|
json_decode(string $json, ?bool $associative = null, int $depth = 512, int $flags = 0): mixed |
Parse JSON. Pass true as the second argument for arrays instead of objects. Invalid JSON fails the expression. | json_decode('{"a": 1}', true) → {"a":1} |
json_encode(mixed $value, int $flags = 0, int $depth = 512): string |
Write a value as JSON. Invalid input fails the expression. Inside {{ }} the result is HTML-escaped; use {!! !!} to keep the quotes. | json_encode(['a' => 1, 'b' => [true, null]]) → "{\"a\":1,\"b\":[true,null]}" |
JSONPath
Section titled “JSONPath”| Function | What it does | Example |
|---|---|---|
jsonpath(mixed $data, string $path): mixed |
Query a value with a JSONPath expression (RFC 9535). A query with a wildcard or filter returns a list. | jsonpath(['items' => [['sku' => 'A'], ['sku' => 'B']]], '$.items[*].sku') → ["A","B"] |
| Function | What it does | Example |
|---|---|---|
now(DateTimeZone|string|null $tz = null): Carbon |
The current date and time, as a date you can call methods on. | now()->addDay()->isFuture() → true |
today(DateTimeZone|string|null $tz = null): Carbon |
Today at midnight. | today()->format('H:i') → "00:00" |
Helpers
Section titled “Helpers”| Function | What it does | Example |
|---|---|---|
blank(mixed $value): bool |
Whether a value is empty: null, an empty or whitespace-only string, or an empty array. 0 and false are not blank. | blank(' ') → true |
class_basename($class): string |
The last part of a class name. | class_basename('App\Models\Flow') → "Flow" |
data_fill(mixed &$target, string|array $key, mixed $value): mixed |
Set a value at a dot path of an array held in a variable, only where nothing is set yet. | @php $data = ['a' => 1]; $data = data_fill($data, 'b', 2); @endphp{{ implode(',', array_keys($data)) }} → "a,b" |
data_forget(mixed &$target, string|array|int|null $key): mixed |
Remove the value at a dot path of an array held in a variable. | @php $data = ['a' => 1, 'b' => 2]; $data = data_forget($data, 'b'); @endphp{{ implode(',', array_keys($data)) }} → "a" |
data_get(mixed $target, array|int|string|null $key, mixed $default = null): mixed |
Read a value at a dot path, with a default when it is absent. Works on arrays and objects alike. | data_get(['order' => ['lines' => [['sku' => 'A']]]], 'order.lines.0.sku') → "A" |
data_set(mixed &$target, array|string $key, mixed $value, bool $overwrite = true): mixed |
Set a value at a dot path of an array held in a variable. | @php $data = ['a' => 1]; $data = data_set($data, 'b.c', 2); @endphp{{ $data['b']['c'] }} → "2" |
e($value, $doubleEncode = true): string |
Escape a string for HTML. | e('<b>') → "<b>" |
filled(mixed $value): bool |
The opposite of blank(). | filled('x') → true |
head($array) |
The first element. | head([3, 2, 1]) → 3 |
last($array) |
The last element. | last([3, 2, 1]) → 1 |
optional(mixed $value = null, ?callable $callback = null): mixed |
Read a property of a value that may be null without failing; ?-> says the same more briefly. | optional(null)->name → null |
rescue(callable $callback, $rescue = null, $report = true) |
Run a callback and return a fallback if it fails. Pass false as the third argument. | rescue(fn () => intdiv(1, 0), 0, false) → null |
tap($value, $callback = null) |
Call a callback with a value, then return the value itself. | tap(5, fn ($n) => $n * 2) → 5 |
transform($value, callable $callback, $default = null) |
Call a callback with a value when it is filled, and return what the callback returns. | transform(5, fn ($n) => $n * 2) → 10 |
value(mixed $value, mixed ...$args): mixed |
A value, or the result of calling it when it is a callback. | value(fn () => 'computed') → "computed" |
when(mixed $condition, mixed $value, mixed $default = null): mixed |
A value when a condition holds, else the default. | when(true, 'yes', 'no') → "yes" |
with($value, ?callable $callback = null) |
Pass a value through a callback. | with(5, fn ($n) => $n + 1) → 6 |
Helper methods
Section titled “Helper methods”Laravel’s helper classes, called as Str::slug(…), Arr::get(…), Number::format(…) and Carbon::parse(…). Only the methods listed here are allowed.
| Method | What it does | Example |
|---|---|---|
Str::after($subject, $search) |
Return the remainder of a string after the first occurrence of a given value. | Str::after('user@example.com', '@') → "example.com" |
Str::afterLast($subject, $search) |
Return the remainder of a string after the last occurrence of a given value. | Str::afterLast('a/b/c', '/') → "c" |
Str::apa($value) |
Convert the given string to APA-style title case. | |
Str::ascii($value, $language = 'en') |
Transliterate a UTF-8 value to ASCII. | |
Str::before($subject, $search) |
Get the portion of a string before the first occurrence of a given value. | Str::before('user@example.com', '@') → "user" |
Str::beforeLast($subject, $search) |
Get the portion of a string before the last occurrence of a given value. | Str::beforeLast('a/b/c', '/') → "a/b" |
Str::between($subject, $from, $to) |
Get the portion of a string between two given values. | Str::between('[draft]', '[', ']') → "draft" |
Str::betweenFirst($subject, $from, $to) |
Get the smallest possible portion of a string between two given values. | |
Str::camel($value) |
Convert a value to camel case. | Str::camel('first_name') → "firstName" |
Str::charAt($subject, $index) |
Get the character at the specified index. | |
Str::chopEnd($subject, $needle) |
Remove the given string(s) if it exists at the end of the haystack. | |
Str::chopStart($subject, $needle) |
Remove the given string(s) if it exists at the start of the haystack. | |
Str::contains($haystack, $needles, $ignoreCase = false) |
Determine if a given string contains a given substring. | Str::contains('Publicus', 'LIC', true) → true |
Str::containsAll($haystack, $needles, $ignoreCase = false) |
Determine if a given string contains all array values. | |
Str::convertCase(string $string, int $mode = Illuminate\Support\MB_CASE_FOLD, ?string $encoding = 'UTF-8') |
Convert the case of a string. | |
Str::deduplicate(string $string, array|string $characters = ' ') |
Replace consecutive instances of a given character with a single character in the given string. | |
Str::doesntContain($haystack, $needles, $ignoreCase = false) |
Determine if a given string doesn’t contain a given substring. | |
Str::doesntEndWith($haystack, $needles) |
Determine if a given string doesn’t end with a given substring. | |
Str::doesntStartWith($haystack, $needles) |
Determine if a given string doesn’t start with a given substring. | |
Str::endsWith($haystack, $needles) |
Determine if a given string ends with a given substring. | Str::endsWith('invoice.pdf', ['.pdf', '.png']) → true |
Str::excerpt($text, $phrase = '', $options = []) |
Extracts an excerpt from text that matches the first instance of a phrase. | Str::excerpt('The quick brown fox jumps', 'brown', ['radius' => 4]) → "...ick brown fox..." |
Str::finish($value, $cap) |
Cap a string with a single instance of a given value. | Str::finish('https://example.com', '/') → "https://example.com/" |
Str::fromBase64($string, $strict = false) |
Decode the given Base64 encoded string. | |
Str::headline($value) |
Convert the given string to proper case for each word. | Str::headline('order_created_at') → "Order Created At" |
Str::initials($value, $capitalize = false) |
Get the “initials” representing each word in the provided string, optionally capitalizing. | Str::initials('Ada Lovelace') → "AL" |
Str::inlineMarkdown($string, array $options = [], array $extensions = []) |
Converts inline Markdown into HTML. | |
Str::is($pattern, $value, $ignoreCase = false) |
Determine if a given string matches a given pattern. | |
Str::isAscii($value) |
Determine if a given string is 7 bit ASCII. | |
Str::isJson($value) |
Determine if a given value is valid JSON. | Str::isJson('{"a": 1}') → true |
Str::isMatch($pattern, $value) |
Determine if a given string matches a given pattern. | |
Str::isUlid($value) |
Determine if a given value is a valid ULID. | |
Str::isUrl($value, array $protocols = []) |
Determine if a given value is a valid URL. | Str::isUrl('https://publicus.cloud') → true |
Str::isUuid($value, $version = null) |
Determine if a given value is a valid UUID. | |
Str::kebab($value) |
Convert a string to kebab case. | Str::kebab('firstName') → "first-name" |
Str::lcfirst($string) |
Make a string’s first character lowercase. | |
Str::length($value, $encoding = null) |
Return the length of the given string. | Str::length('café') → 4 |
Str::limit($value, $limit = 100, $end = '...', $preserveWords = false) |
Limit the number of characters in a string. | Str::limit('The quick brown fox', 9) → "The quick..." |
Str::lower($value) |
Convert the given string to lower-case. | Str::lower('ÉCOLE') → "école" |
Str::ltrim($value, $charlist = null) |
Remove all whitespace from the beginning of a string. | |
Str::markdown($string, array $options = [], array $extensions = []) |
Converts GitHub flavored Markdown into HTML. | |
Str::mask($string, $character, $index, $length = null, $encoding = 'UTF-8') |
Masks a portion of a string with a repeated character. | Str::mask('0612345678', '*', 3) → "061*******" |
Str::match($pattern, $subject) |
Get the string matching the given pattern. | |
Str::matchAll($pattern, $subject) |
Get the string matching the given pattern. | |
Str::numbers($value) |
Remove all non-numeric characters from a string. | |
Str::of($string) |
Get a new stringable object from the given string. | (string) Str::of(' hello ')->trim()->upper() → "HELLO" |
Str::padBoth($value, $length, $pad = ' ') |
Pad both sides of a string with another. | |
Str::padLeft($value, $length, $pad = ' ') |
Pad the left side of a string with another. | Str::padLeft('7', 3, '0') → "007" |
Str::padRight($value, $length, $pad = ' ') |
Pad the right side of a string with another. | |
Str::pascal($value, bool $normalize = false) |
Convert a value to Pascal case. | |
Str::plural($value, $count = 2, $prependCount = false) |
Get the plural form of an English word. | Str::plural('box') → "boxes" |
Str::pluralPascal($value, $count = 2) |
Pluralize the last word of an English, Pascal caps case string. | |
Str::pluralStudly($value, $count = 2) |
Pluralize the last word of an English, studly caps case string. | |
Str::position($haystack, $needle, $offset = 0, $encoding = null) |
Find the multi-byte safe position of the first occurrence of a given substring in a string. | |
Str::random($length = 16) |
Generate a more truly “random” alpha-numeric string. | |
Str::remove($search, $subject, $caseSensitive = true) |
Remove any occurrence of the given string in the subject. | |
Str::repeat(string $string, int $times) |
Repeat the given string. | |
Str::replace($search, $replace, $subject, $caseSensitive = true) |
Replace the given value in the given string. | Str::replace('-', ' ', 'a-b-c') → "a b c" |
Str::replaceArray($search, $replace, $subject) |
Replace a given value in the string sequentially with an array. | |
Str::replaceEnd($search, $replace, $subject) |
Replace the last occurrence of a given value if it appears at the end of the string. | |
Str::replaceFirst($search, $replace, $subject) |
Replace the first occurrence of a given value in the string. | |
Str::replaceLast($search, $replace, $subject) |
Replace the last occurrence of a given value in the string. | |
Str::replaceMatches($pattern, $replace, $subject, $limit = -1) |
Replace the patterns matching the given regular expression. | |
Str::replaceStart($search, $replace, $subject) |
Replace the first occurrence of the given value if it appears at the start of the string. | |
Str::reverse(string $value) |
Reverse the given string. | |
Str::rtrim($value, $charlist = null) |
Remove all whitespace from the end of a string. | |
Str::singular($value) |
Get the singular form of an English word. | Str::singular('boxes') → "box" |
Str::slug($title, $separator = '-', $language = 'en', $dictionary = […]) |
Generate a URL friendly “slug” from a given string. | Str::slug('Hello World') → "hello-world" |
Str::snake($value, $delimiter = '_') |
Convert a string to snake case. | Str::snake('firstName') → "first_name" |
Str::squish($value) |
Remove all “extra” blank space from the given string. | Str::squish(' a b ') → "a b" |
Str::start($value, $prefix) |
Begin a string with a single instance of a given value. | Str::start('path', '/') → "/path" |
Str::startsWith($haystack, $needles) |
Determine if a given string starts with a given substring. | Str::startsWith('INV-001', 'INV-') → true |
Str::studly($value, bool $normalize = false) |
Convert a value to studly caps case. | Str::studly('first_name') → "FirstName" |
Str::substr($string, $start, $length = null, $encoding = 'UTF-8') |
Returns the portion of the string specified by the start and length parameters. | |
Str::substrCount($haystack, $needle, $offset = 0, $length = null) |
Returns the number of substring occurrences. | |
Str::substrReplace($string, $replace, $offset = 0, $length = null) |
Replace text within a portion of a string. | |
Str::swap(array $map, $subject) |
Swap multiple keywords in a string with other keywords. | |
Str::take($string, int $limit): string |
Take the first or last {$limit} characters of a string. | |
Str::title($value) |
Convert the given string to proper case. | Str::title('hello world') → "Hello World" |
Str::toBase64($string): string |
Convert the given string to Base64 encoding. | |
Str::toStringOr($value, $fallback) |
Convert the given value to a string or return the given fallback on failure. | |
Str::transliterate($string, $unknown = '?', $strict = false) |
Transliterate a string to its closest ASCII representation. | |
Str::trim($value, $charlist = null) |
Remove all whitespace from both ends of a string. | |
Str::ucfirst($string) |
Make a string’s first character uppercase. | Str::ucfirst('élan') → "Élan" |
Str::ucsplit($string) |
Split a string into pieces by uppercase characters. | |
Str::ucwords($string, $separators = " \t\r\n\f\v") |
Capitalize the first character of each word in a string. | |
Str::unwrap($value, $before, $after = null) |
Unwrap the string with the given strings. | |
Str::upper($value) |
Convert the given string to upper-case. | Str::upper('école') → "ÉCOLE" |
Str::wordCount($string, $characters = null) |
Get the number of words a string contains. | Str::wordCount('one two three') → 3 |
Str::words($value, $words = 100, $end = '...') |
Limit the number of words in a string. | Str::words('The quick brown fox', 2) → "The quick..." |
Str::wordWrap($string, $characters = 75, $break = "\n", $cutLongWords = false) |
Wrap a string to a given number of characters. | |
Str::wrap($value, $before, $after = null) |
Wrap the string with the given strings. |
| Method | What it does | Example |
|---|---|---|
Arr::accessible($value) |
Determine whether the given value is array accessible. | |
Arr::add($array, $key, $value) |
Add an element to an array using “dot” notation if it doesn’t exist. | |
Arr::boolean(ArrayAccess|array $array, string|int|null $key, ?bool $default = null): bool |
Get a boolean item from an array using “dot” notation. | |
Arr::collapse($array) |
Collapse an array of arrays into a single array. | Arr::collapse([[1, 2], [3]]) → [1,2,3] |
Arr::crossJoin(...$arrays) |
Cross join the given arrays, returning all possible permutations. | |
Arr::divide($array) |
Divide an array into two arrays. One with keys and the other with values. | |
Arr::dot($array, $prepend = '', $depth = Illuminate\Support\INF) |
Flatten a multi-dimensional associative array with dots. | Arr::dot(['a' => ['b' => 1]]) → {"a.b":1} |
Arr::every($array, callable $callback) |
Determine if all items pass the given truth test. | |
Arr::except($array, $keys) |
Get all of the given array except for a specified array of keys. | Arr::except(['a' => 1, 'b' => 2], ['b']) → {"a":1} |
Arr::exceptValues($array, $values, $strict = false) |
Get all of the given array except for a specified array of values. | |
Arr::exists($array, $key) |
Determine if the given key exists in the provided array. | |
Arr::first($array, ?callable $callback = null, $default = null) |
Return the first element in an iterable passing a given truth test. | Arr::first([1, 5, 10], fn ($n) => $n > 3) → 5 |
Arr::flatten($array, $depth = Illuminate\Support\INF) |
Flatten a multi-dimensional array into a single level. | Arr::flatten([[1, [2]], [3]]) → [1,2,3] |
Arr::float(ArrayAccess|array $array, string|int|null $key, ?float $default = null): float |
Get a float item from an array using “dot” notation. | |
Arr::forget(&$array, $keys) |
Remove one or many array items from a given array using “dot” notation. | |
Arr::from($items) |
Get the underlying array of items from the given argument. | |
Arr::get($array, $key, $default = null) |
Get an item from an array using “dot” notation. | Arr::get(['a' => ['b' => 1]], 'a.b') → 1 |
Arr::has($array, $keys) |
Check if an item or items exist in an array using “dot” notation. | Arr::has(['a' => ['b' => 1]], 'a.b') → true |
Arr::hasAll($array, $keys) |
Determine if all keys exist in an array using “dot” notation. | |
Arr::hasAny($array, $keys) |
Determine if any of the keys exist in an array using “dot” notation. | |
Arr::integer(ArrayAccess|array $array, string|int|null $key, ?int $default = null): int |
Get an integer item from an array using “dot” notation. | |
Arr::isAssoc(array $array) |
Determines if an array is associative. | |
Arr::isList($array) |
Determines if an array is a list. | |
Arr::join($array, $glue, $finalGlue = '') |
Join all items using a string. The final items can use a separate glue string. | Arr::join(['a', 'b', 'c'], ', ', ' and ') → "a, b and c" |
Arr::keyBy($array, $keyBy) |
Key an associative array by a field or using a callback. | Arr::keyBy([['id' => 'x', 'n' => 1]], 'id') → {"x":{"id":"x","n":1}} |
Arr::last($array, ?callable $callback = null, $default = null) |
Return the last element in an array passing a given truth test. | Arr::last([1, 5, 10], fn ($n) => $n < 8) → 5 |
Arr::map(array $array, callable $callback) |
Run a map over each of the items in the array. | |
Arr::mapSpread(array $array, callable $callback) |
Run a map over each nested chunk of items. | |
Arr::mapWithKeys(array $array, callable $callback) |
Run an associative map over each of the items. | |
Arr::only($array, $keys) |
Get a subset of the items from the given array. | Arr::only(['a' => 1, 'b' => 2, 'c' => 3], ['a', 'c']) → {"a":1,"c":3} |
Arr::onlyValues($array, $values, $strict = false) |
Get a subset of the items from the given array by value. | |
Arr::partition($array, callable $callback) |
Partition the array into two arrays using the given callback. | |
Arr::pluck($array, $value, $key = null) |
Pluck an array of values from an array. | Arr::pluck([['id' => 1], ['id' => 2]], 'id') → [1,2] |
Arr::prepend($array, $value, $key = null) |
Push an item onto the beginning of an array. | |
Arr::prependKeysWith($array, $prependWith) |
Prepend the key names of an associative array. | |
Arr::pull(&$array, $key, $default = null) |
Get a value from the array, and remove it. | |
Arr::push(ArrayAccess|array &$array, string|int|null $key, mixed ...$values): ArrayAccess|array |
Push an item into an array using “dot” notation. | |
Arr::query($array) |
Convert the array into a query string. | Arr::query(['page' => 2, 'q' => 'a b']) → "page=2&q=a%20b" |
Arr::random($array, $number = null, $preserveKeys = false) |
Get one or a specified number of random values from an array. | |
Arr::reject($array, callable $callback) |
Filter the array using the negation of the given callback. | |
Arr::select($array, $keys) |
Select an array of values from an array. | |
Arr::set(&$array, $key, $value) |
Set an array item to a given value using “dot” notation. | |
Arr::shuffle($array) |
Shuffle the given array and return the result. | |
Arr::sole($array, ?callable $callback = null) |
Get the first item in the array, but only if exactly one item exists. Otherwise, throw an exception. | |
Arr::some($array, callable $callback) |
Determine if some items pass the given truth test. | |
Arr::sort($array, $callback = null) |
Sort the array using the given callback or “dot” notation. | |
Arr::sortDesc($array, $callback = null) |
Sort the array in descending order using the given callback or “dot” notation. | Arr::sortDesc([1, 3, 2]) → {"1":3,"2":2,"0":1} |
Arr::sortRecursive($array, $options = Illuminate\Support\SORT_REGULAR, $descending = false) |
Recursively sort an array by keys and values. | |
Arr::sortRecursiveDesc($array, $options = Illuminate\Support\SORT_REGULAR) |
Recursively sort an array by keys and values in descending order. | |
Arr::string(ArrayAccess|array $array, string|int|null $key, ?string $default = null): string |
Get a string item from an array using “dot” notation. | |
Arr::take($array, $limit) |
Take the first or last {$limit} items from an array. | |
Arr::toCssClasses($array) |
Conditionally compile classes from an array into a CSS class list. | |
Arr::toCssStyles($array) |
Conditionally compile styles from an array into a style list. | |
Arr::undot($array) |
Convert a flatten “dot” notation array into an expanded array. | Arr::undot(['a.b' => 1]) → {"a":{"b":1}} |
Arr::where($array, callable $callback) |
Filter the array using the given callback. | Arr::where([1, 2, 3, 4], fn ($n) => $n % 2 === 0) → {"1":2,"3":4} |
Arr::whereNotNull($array) |
Filter items where the value is not null. | |
Arr::wrap($value) |
If the given value is not an array and not null, wrap it in one. | Arr::wrap('a') → ["a"] |
Number
Section titled “Number”| Method | What it does | Example |
|---|---|---|
Number::abbreviate(int|float $number, int $precision = 0, ?int $maxPrecision = null) |
Convert the number to its human-readable equivalent. | Number::abbreviate(1500000, 1) → "1.5M" |
Number::clamp(int|float $number, int|float $min, int|float $max) |
Clamp the given number between the given minimum and maximum. | Number::clamp(15, 0, 10) → 10 |
Number::currency(int|float $number, string $in = '', ?string $locale = null, ?int $precision = null) |
Convert the given number to its currency equivalent. | Number::currency(1234.5) → "$1,234.50" |
Number::fileSize(int|float $bytes, int $precision = 0, ?int $maxPrecision = null) |
Convert the given number to its file size equivalent. | Number::fileSize(2048) → "2 KB" |
Number::forHumans(int|float $number, int $precision = 0, ?int $maxPrecision = null, bool $abbreviate = false) |
Convert the number to its human-readable equivalent. | Number::forHumans(1500000) → "2 million" |
Number::format(int|float $number, ?int $precision = null, ?int $maxPrecision = null, ?string $locale = null) |
Format the given number according to the current locale. | Number::format(1234.5, 2) → "1,234.50" |
Number::ordinal(int|float $number, ?string $locale = null) |
Convert the given number to ordinal form. | Number::ordinal(3) → "3rd" |
Number::pairs(int|float $to, int|float $by, int|float $start = 0, int|float $offset = 1) |
Split the given number into pairs of min/max values. | |
Number::parse(string $string, ?int $type = NumberFormatter::TYPE_DOUBLE, ?string $locale = null): int|float|false |
Parse the given string according to the specified format type. | |
Number::parseFloat(string $string, ?string $locale = null): float|false |
Parse a string into a float according to the specified locale. | |
Number::parseInt(string $string, ?string $locale = null): int|false |
Parse a string into an integer according to the specified locale. | |
Number::percentage(int|float $number, int $precision = 0, ?int $maxPrecision = null, ?string $locale = null) |
Convert the given number to its percentage equivalent. | Number::percentage(12.5, 1) → "12.5%" |
Number::spell(int|float $number, ?string $locale = null, ?int $after = null, ?int $until = null) |
Spell out the given number in the given locale. | Number::spell(42) → "forty-two" |
Number::spellOrdinal(int|float $number, ?string $locale = null) |
Spell out the given number in the given locale in ordinal form. | |
Number::summarize(int|float $number, int $precision = 0, ?int $maxPrecision = null, array $units = []) |
Convert the number to its human-readable equivalent. | |
Number::trim(int|float $number) |
Remove any trailing zero digits after the decimal point of the given number. | |
Number::withCurrency(string $currency, callable $callback) |
Execute the given callback using the given currency. | |
Number::withLocale(string $locale, callable $callback) |
Execute the given callback using the given locale. |
Carbon
Section titled “Carbon”| Method | What it does | Example |
|---|---|---|
Carbon::canBeCreatedFromFormat(?string $date, string $format): bool |
Whether a string can be read with the given format. | Carbon::canBeCreatedFromFormat('24/10/2026', 'd/m/Y') → true |
Carbon::create($year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $timezone = null) |
A date from year, month, day, hour, minute and second. | Carbon::create(2026, 10, 24)->format('l') → "Saturday" |
Carbon::createFromDate($year = null, $month = null, $day = null, $timezone = null) |
A date from year, month and day, at the current time. | |
Carbon::createFromFormat($format, $time, $timezone = null) |
A date read from a string with the given format. | Carbon::createFromFormat('d-m-Y', '24-10-2026')->toDateString() → "2026-10-24" |
Carbon::createFromTime($hour = 0, $minute = 0, $second = 0, $timezone = null) |
Today at the given hour, minute and second. | |
Carbon::createFromTimestamp(string|int|float $timestamp, DateTimeZone|string|int|null $timezone = null) |
A date from a Unix timestamp in seconds. | Carbon::createFromTimestamp(0, 'UTC')->toIso8601String() → "1970-01-01T00:00:00+00:00" |
Carbon::createFromTimestampMs(string|int|float $timestamp, DateTimeZone|string|int|null $timezone = null) |
A date from a Unix timestamp in milliseconds. | |
Carbon::createFromTimestampUTC(string|int|float $timestamp) |
A date in UTC from a Unix timestamp in seconds. | |
Carbon::createMidnightDate($year = null, $month = null, $day = null, $timezone = null) |
A date from year, month and day, at midnight. | |
Carbon::createStrict(?int $year = 0, ?int $month = 1, ?int $day = 1, ?int $hour = 0, ?int $minute = 0, ?int $second = 0, $timezone = null) |
Like create(), but failing on an out-of-range value instead of rolling it over. | |
Carbon::getLastErrors(): array|false |
The warnings and errors of the last date read from a string. | |
Carbon::hasFormat(string $date, string $format): bool |
Whether a string matches the given format. | Carbon::hasFormat('2026-10-24', 'Y-m-d') → true |
Carbon::hasFormatWithModifiers(?string $date, string $format): bool |
Whether a string matches the given format, modifiers included. | |
Carbon::isImmutable(): bool |
Whether dates of this class are immutable. Always false here. | |
Carbon::make($var, DateTimeZone|string|null $timezone = null) |
A date from a string or date, or null for anything else. | Carbon::make('2026-10-24')->format('Y') → "2026" |
Carbon::now(DateTimeZone|string|int|null $timezone = null) |
The current date and time. | Carbon::now()->addHour()->isFuture() → true |
Carbon::parse(DateTimeInterface|Carbon\WeekDay|Carbon\Month|string|int|float|null $time, DateTimeZone|string|int|null $timezone = null) |
A date read from a string in any common format. | Carbon::parse('2026-10-24')->addDays(7)->format('Y-m-d') → "2026-10-31" |
Carbon::today(DateTimeZone|string|int|null $timezone = null) |
Today at midnight. | Carbon::today()->format('H:i') → "00:00" |
Carbon::tomorrow(DateTimeZone|string|int|null $timezone = null) |
Tomorrow at midnight. | Carbon::tomorrow()->isFuture() → true |
Carbon::yesterday(DateTimeZone|string|int|null $timezone = null) |
Yesterday at midnight. | Carbon::yesterday()->isPast() → true |