In this tutorial, We will learn how to wrap() function. The Arr::wrap method return value in an array.
Example:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\FileController;
use Illuminate\Support\Arr;
class HomeController extends Controller {
/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index() {
$string1 = 'Car';
$array1 = Arr::wrap($string1);
print_r($array1);
$string2 = 'LARAVEL';
$array2 = Arr::wrap($string2);
print_r($array2);
}
}
Output:
['Car']
['LARAVEL'] |
Thanks, May this example will help you.