Showing 7 of 1,216 result(s)
The following examples are trivial use cases of the each method in that we iterate each element of the collection and echo the element: The each method does not explicitly allow the modification of a collection's items, and simply returns a...
The each method can also be used with higher order messaging, which allows us to invoke collection methods and access properties on objects using PHP's property accessors syntax. In the following example, we will create modify our User class to...
The following example demonstrates the basic use of the mapSpread method. We will first create a series of numbers using PHP's range function; afterwards, we will split the collection into smaller pieces using the chunk method and then label each...
We can use the mapSpread method to replicate the behavior of LINQ's Zip operator that was added in version 4 of the .NET Framework. LINQ's Zip operator enumerates two collections and allows a new collection to be created by executing a function...
The following examples demonstrate the behavior of the filter method; the results of the filtering process will appear above the method invocation as a comment:
The filter method can also be used with higher order messaging, which allows us to invoke collection methods and access object instance properties using PHP's property accessors syntax. In the reject section, we implemented a Product class that...
The following is a trivial example of the partition where we create two partitions, one containing the vowels of a sentence and the other containing the consonants of the sentence. We will then take the results of the partition method and pass...
The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.