App\Libraries\Arr::indexToAssoc PHP Method

indexToAssoc() public static method

Optionally will capitalize the values for presentation.
public static indexToAssoc ( array $array, boolean $capitalizeValues = false ) : array
$array array
$capitalizeValues boolean
return array
    public static function indexToAssoc(array $array, $capitalizeValues = false)
    {
        $keys = array_values($array);
        $values = array_values($array);
        if ($capitalizeValues) {
            foreach ($array as &$value) {
                $value = ucfirst($value);
            }
        }
        return array_combine($keys, $values);
    }

Usage Example

 /**
  * @return \Illuminate\View\View
  */
 public function profile()
 {
     $user = Auth::user();
     Audit::log(Auth::user()->id, trans('general.audit-log.category-profile'), trans('general.audit-log.msg-profile-show', ['username' => $user->username]));
     $page_title = trans('general.page.profile.title');
     $page_description = trans('general.page.profile.description', ['full_name' => $user->full_name]);
     $readOnlyIfLDAP = 'ldap' == $user->auth_type ? 'readonly' : '';
     $perms = $this->perm->pushCriteria(new PermissionsByNamesAscending())->all();
     $themes = \Theme::getList();
     $themes = Arr::indexToAssoc($themes, true);
     $theme = $user->settings()->get('theme');
     $time_zones = \DateTimeZone::listIdentifiers();
     $time_zone = $user->settings()->get('time_zone');
     $tzKey = array_search($time_zone, $time_zones);
     $time_format = $user->settings()->get('time_format');
     $locales = Setting::get('app.supportedLocales');
     $locale = $user->settings()->get('locale');
     return view('user.profile', compact('user', 'perms', 'themes', 'theme', 'time_zones', 'tzKey', 'time_format', 'locale', 'locales', 'readOnlyIfLDAP', 'page_title', 'page_description'));
 }