Search

Showing 7 of 587 result(s)

/blog/2018/04/11/laravel-5-conditionally-retrieving-array-values-with-where#content-example-use

In the following example, we will examine how to compare just the values of the arrays. Assume we have an array of numbers, from 0 to 100 : $numbers = range(0, 100); An array of all numbers less than or equal to 10 can be created like so:...

/blog/2018/04/11/laravel-5-creating-combinations-of-elements-with-crossjoin

The crossJoin method can be used to combine the input arrays; the resulting array will contain all of the possible combinations of the input array values.The signature of the crossJoin method is: If you are unfamiliar with the ...$arrays syntax,...

/blog/2018/04/11/laravel-5-ensuring-a-value-is-an-array-with-wrap#content-example-use

In the introduction of this section, we saw this example code: We could do the same thing using the wrap method like so: The Arr::wrap method will not do anything to the input $value if it is already an array. We can round this section out by...

/blog/2018/04/11/laravel-5-finding-the-first-occurrence-of-an-element-matching-a-condition-with-first#content-example-use

The following code sample is an anonymous function assigned to a variable named $isPostFormat . The following example will use the Str::is helper method to check if a value is of the format /post/* : If a given value satisfies the format, true is...

/blog/2018/04/11/laravel-5-removing-elements-from-an-array-with-forget#content-example-use

Assuming an array is defined as follows: We could remove the first_name value like so: Which would leave the array as follows: Removing multiple items at once is as simple as passing an array as the second argument:

/blog/2018/04/11/laravel-5-retrieving-nested-array-values-with-pluck#content-example-use

Let's use the following class to describe a person: We can create an array of people like so: At this point all we have is a simple Person class definition an array of person objects, called $people . However, it would be really useful if we had...

/blog/2018/04/11/laravel-5-retrieving-nested-array-values-with-pluck#content-working-with-nested-arrays-or-objects

The $key supports dot notation, which implies that we can search for keys at arbitrary depths when constructing the final array. Let's add a new Job class, which will just be a very simple representation of a job: Now we will modify our Person...