Showing 7 of 587 result(s)
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:...
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,...
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...
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...
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:
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...
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...