php - sort Array in specific filename order -



php - sort Array in specific filename order -

how sort next info in order want it?

the array:

array(4) { [21]=> string(7) "2-2.pdf" [22]=> string(7) "2-3.pdf" [23]=> string(7) "2-4.pdf" [24]=> string(5) "2.pdf" }

i want sort:

2.pdf 2-2.pdf 2-3.pdf 2-4.pdf

yes utilize usort in case:

$array = [21=> "2-2.pdf", 22=> "2-3.pdf", 23=> "2-4.pdf",24=> "2.pdf", ]; usort($array, function($a, $b){ $a = str_replace('-', '', $a); $b = str_replace('-', '', $b); homecoming $a - $b; });

php arrays sorting

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -