Let's start quickly, I found the prepend function and I want to share it with you
I will explain you how to work laravel array prepend() function. We will show example of array prepend function to get array prepend element value in laravel.The Arr::prepend method will push an item onto the beginning of an array
$array = ['php', 'laravel', 'html','css'];
$prepended = Arr::prepend($array,'Vue');
print_r($prepended ); //['Vue', 'php', 'laravel', 'html', 'css']
Other use for Dropsdown
User::pluck('name','id')->prepend('Plz Select','');
/*
all: [
"" => "Plz Select"
1 => "User k",
2 => "Euna Dau",
......
]
*/
I hope you enjoyed the code.
Top comments (2)
Neat!
By the way, should the print_r maybe output 'Vue' before 'php'?
You are indeed correct, I modified the article, thanks for the comment.