Showing 7 of 2,041 result(s)
Thinking back on our previous hypothetical scenario, we can be thankful that there is a built in PHP function named array_filter . This function filters elements of an array using a callback function . That callback function will be the lambda...
…array of all numbers less than or equal to 10 can be created like so: $smallNumbers would then look like this: Now that we have looked at how to compare just the array values, let's examine ways to examine both the array key and value. That...
The first step we will take in implementing our language parser is to split the input up into individual characters (we will refer to them as tokens) so they can be analyzed one-by-one. The first reaction might be to reach for str_split : $tokens...
data_set(&$target, $key, $value, $overwrite = true) The data_set helper function can be used to set the value of an item in an array or an object property using dot notation. It accepts a reference to a $target array or object; the $key (array key...
The times static method is similar to PHP's range function, with some extra functionality specific for collections. The times method accepts a $number argument as well as an optional $callback function. The argument supplied for the $number...
In this section, we are going to make adjustments to our project's error handler located within the app/Exceptions/Handler.php file. These changes are going to allow us to store a reference to any exception that is thrown so that we can access it...
The mapToGroups method is similar to the mapToDictionary method, in that the mapToGroups method allows you take a collection of data and reduce it such that the final result is a collection of key/value pairs. The resulting value for each key may...