CKTIS / PHP
natsort()
Řadí řetězce přirozeně s rozlišením velikosti písmen.
Verze: PHP 8.4; repository runtime, production runtime not attested
Syntaxe
natsort(array &$array): trueŘadí řetězce přirozeně s rozlišením velikosti písmen. V názvech souborů skupina číslic umístí file2 před file10. Zachované klíče nemusí být souvislé. Změní argument a vrátí true.
Signatura
natsort(array &$array): true
Výstup příkladu
[[5,3,7],["file1","file2","file10"]]
Příklady
<?php
$files = [7=>"file10",3=>"file2",5=>"file1"];
natsort($files);
echo json_encode([array_keys($files),array_values($files)]);
Výsledek
[[5,3,7],["file1","file2","file10"]]