Laravel 8 Arr::wrap() {#collection-method}
Arr::wrap
函数可以将给定值转换为一个数组。如果给定值已经是一个数组,将不会被转换:
use Illuminate\Support\Arr;
$string = 'Laravel';
$array = Arr::wrap($string);
// ['Laravel']
如果给定值是 null
,将返回一个空数组:
use Illuminate\Support\Arr;
$nothing = null;
$array = Arr::wrap($nothing);
// []