Search

Showing 7 of 1,216 result(s)

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

Let's begin discussing the first helper method be examining the $callback . The $callback is a function that accepts a $key and a $value as its parameters.

/blog/2018/04/11/laravel-5-finding-the-last-occurrence-of-an-element-matching-a-condition-with-last

The last helper method is the logical opposite of the first method. The difference is that the last function will return the last value to satisfy the $callback function. If no value is returned from the $callback function, the $default value is...

/blog/2018/04/11/laravel-5-getting-the-first-element-of-an-array-with-head

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...

/blog/2018/04/11/laravel-5-getting-the-last-element-of-an-array-with-last

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...

/blog/2018/04/11/laravel-5-randomizing-element-order-with-shuffle

The shuffle method can be used to shuffle an input array and then returns the results. This method takes advantage of PHP's shuffle method; therefore, it is not suitable for cryptographic purposes.The signature of the shuffle method is:In the...

/blog/2018/04/11/laravel-5-reducing-a-multi-dimensional-array-to-a-single-dimension-losing-keys-with-flatten

The flatten helper method is similar to the dot method in that it takes a multi-dimensional array and transforms it into a new array with only one dimension. While the dot method preserves the keys by separating them with dots , the flatten method...

/blog/2018/04/11/laravel-5-removing-elements-from-an-array-with-forget

The forget helper method removes items from the given $array . The specified keys are express in dot notation. Mutable Function This function affects the original $array ; because of this you do not have to reassign the original array value to a...