本文介绍了scnadir排序顺序asc将大写字母放在首位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

因此,我尝试对文件夹和文件列表进行排序,并按字母顺序显示它们,如果有人创建了一个以大写字母开头的文件夹,则该问题首先出现,例如,如果我有以下文件夹,则会出现该问题

So I am trying to sort a list of folders and files and display them alphabetical the problem appears that if someone created a folder that starts with a captial letter that folder appears first for example if I had the following folders

Array
(
    [0] => .
    [1] => ..
    [2] => _base
    [3] => template
    [4] => Website
)

我希望在使用scandir(scandir($directory, SCANDIR_SORT_ASCENDING))时看到上面列出的文件夹,但相反,它们会列出为

I would expect when using scandir (scandir($directory, SCANDIR_SORT_ASCENDING)) to see the folders listed out as above but instead that get listed out as

Array
(
    [0] => .
    [1] => ..
    [2] => Website
    [3] => _base
    [4] => template
)

我如何能够以正确的方式对列表进行排序,以使其不区分大小写.

How would I be able to get this list sorted the correct way so that it wouldn't be case sensitive.

推荐答案

这应该对您有用:

natcasesort($array);

这是数组自然忽略的情况

It sort's an array natural ignore case

请参阅: http://php.net/manual/en/function.natcasesort. php

这篇关于scnadir排序顺序asc将大写字母放在首位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 17:29