Showing 7 of 1,697 result(s)
The isAssoc helper method can be used to determine if a given $array is an associative array or not. The provided documentation for the isAssoc method states that an array is associative if it does not have sequential numeric keys beginning with...
The collapse method will also work on collections. There is no special syntax required to use collections with the collapse method: The value of $collapsedArray would then be: Nested collections can also be collapsed: The value of collapsed array...
The head is a simple wrapper around PHP's reset function. This function will return the first element of an array or false if the array is empty. This function does not modify the array.The signature of the head helper function is:Consider the...
The last function is the logical opposite of the head function: it will return the last element of an array without modifying the array. The last helper function is a wrapper around PHP's end function.The signature of the last function is:Using...
Consider the following array: If we flatten the array like so: the resulting array would be:
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:
The following example demonstrates the dot method without using the $prepend argument: The final array would look like this: The dot method also accepts a value for $prepend which will be added to the beginning of all the newly generated keys....