Stack Overflow Asked on November 24, 2021
I tried to use the helper function array_sort()
, but it returns an undefined function error. Please see my code below.
DashboardController
dd(array_sort($get_all_available_city));
I’ve created helpers.php
by the way. Maybe it affects the functionality. But didn’t override the array_sort()
, and also I didn’t put namespace on it.
UPDATE
I’m using laravel 7.
You can't use string and array helpers from Laravel 6. laravel 6 removed helpers function from repo. You can use IlluminateSupportArr classes for helpers.
use IlluminateSupportArr;
Arr:::sort($get_all_available_city);
If you want to use helpers functions as array_sort then you need to install new composer package with following command :
composer require laravel/helpers
Then you can access :
array_sort($get_all_available_city);
Answered by sta on November 24, 2021
You can follow the official documentation of Laravel here
use IlluminateSupportArr;
$array = ['Desk', 'Table', 'Chair'];
$sorted = Arr::sort($array);
Answered by Tarequzzaman Khan on November 24, 2021
Laravel 7 doesn't seem to use the array_*
calls anymore. Use Arr::sort() instead.
dd(Arr::sort($get_all_available_city));
Answered by aynber on November 24, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP