laravel的 array 函数

代码如下:  routes.php文件

// 获⃣取⃣数⃣组⃣的⃣第⃣一⃣个⃣
Route::get('/helper', function () {
    $arr = [1, 2, 4];
    return head($arr);
});

// 添加数组元素
Route::get('/helper/array_add', function () {
    $arr = [
        'name' => 'Bob',
        'age' => '18'

    ];
    return array_add($arr, 'job', 'work');
});

// 返回除了age的其他元素
Route::get('/helper/array_excepte', function () {
    $arr = [
        'name' => 'Bob',
        'age' => '18'

    ];
    return array_except($arr, 'age');
});
原文地址:https://www.cnblogs.com/mafeng/p/5762914.html