Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Laravel News:
Unwrapping array_wrap()
Nov 30, 2018 @ 09:34:32

On the Laravel News site they have a new post that "unwraps" the array_wrap helper that makes it easier to normalize values into arrays and removes the need for manually checking if a variable is an array or set before using it like one.

Laravel has a wrap method and array_wrap() helper to normalize values into an array. Raul @rcubitto shared this nice tip about it on Twitter and before seeing his Tweet I wasn’t aware of this method.

They include an example of the helper function in use and share some of the responses to his tweet including questions of how it's different than casting to an array. They answer this by talking about more complex values and how the helper is useful for null values and creating consistency in your application.

tagged: laravel helper function array arraywrap tutorial

Link: https://laravel-news.com/array_wrap