Filters the array items by a given condition.

/**
 * Filters the array items by a given condition.
 *
 * @param string $key      Key of the array or object to used for comparison.
 * @param string $operator Operator used for comparison.
 *                         operators: in, nin, lt, <, lte,
 *                                    >, gt, gte, >=, contains, ncontains
 *                                    >=, <=, like, nlike, regexp, nregexp,
 *                                    eq, =, neq, !=, starts_with,
 *                                    ends_with, between, nbetween, older, newer
 * @param mixed  $value    Value used for comparison.
 *
 * @return self Returns instance of The Arrays class.
 */
public function where(string $key, string $operator, $value): self

Examples

$result = Arrays::create([
                    0 => ['title' => 'FòôBar'],
                    1 => ['title' => 'BarFòô'],
                ])
                ->where('title', '=', 'FòôBar')
                ->toArray();
);

Operators

Equal to eq =

Filter your array items by checking if your custom attribute (key) has a value that is equal to one of the values provided.

Use-cases: Get collection that is refered to another in a 1:N relationship or if you want to get collection with a specific value in one of it's fields.

Not equal to neq <> !=

Filter your array items by checking if your custom attribute (key) does not have a value that is equal to one of the values provided.

Lower than lt <

Filter your array items by checking if your custom attribute (key) has a value that is lower than one of the values provided.

Greater than gt >

Filter your array items by checking if your custom attribute (key) has a value that is greater than one of the values provided.

Lower than or equal to lte <=

Filter your array items by checking if your custom attribute (key) has a value that is lower than or equal to one of the values provided.

Greater than or equal to gt >=

Filter your array items by checking if your custom attribute (key) has a value that is greater than or equal to one of the values provided.

Included in an array of values in

Filter your array items by checking if your custom array attribute (key) contains one of the values provided. As soon as one of the provided values separated with, are in the array field, the entry object will be in the response.

Use-cases: Get all content array items that is refered to others in a N:N relationship or if you want to get all entries with a specific value in one of it's array fields.

Isn't included in an array of values nin

Filter your entries by checking if your custom array attribute (key) is not contains one of the values provided.

Use-cases: Get all content array items that is not refered to others in a N:N relationship or if you want to get all entries with a specific value that is not in one of it's array fields.

Contains the substring contains like

Filter your array items by checking if your custom attribute (key) has a value that is "like" the value provided.

Not Contains the substring ncontains nlike

Filter your array items by checking if your custom attribute (key) has a value that is "not like" the value provided.

Starts with starts_with

Filter your array items by checking if your custom attribute (key) has a value that is "starts with" the value provided.

Ends with ends_with

Filter your array items by checking if your custom attribute (key) has a value that is "ends with" the value provided.

Older older

Filter your array items by checking if your custom attribute (key) is older than the value provided.

Newer newer

Filter your array items by checking if your custom attribute (key) is newer than the value provided.

Between between

Filter your array items by checking if your custom attribute (key) is between the value provided.

Not Between nbetween

Filter your array items by checking if your custom attribute (key) is not between the value provided.

Regexp regexp

Filter your array items by checking if your custom attribute (key) is match the provided regexp.

Not Regexp regexp nregexp

Filter your array items by checking if your custom attribute (key) is not match the provided regexp.

Getting Started

Methods