CKTIS / PHP
natsort()
Zoradí reťazce prirodzene s rozlíšením veľkosti písmen.
Verzia: PHP 8.4; repository runtime, production runtime not attested
Syntax
natsort(array &$array): trueZoradí reťazce prirodzene s rozlíšením veľkosti písmen. V názvoch súborov skupina číslic umiestni file2 pred file10. Zachované kľúče nemusia byť súvislé. Zmení argument a vráti true.
Signatúra
natsort(array &$array): true
Výstup príkladu
[[5,3,7],["file1","file2","file10"]]
Príklady
<?php
$files = [7=>"file10",3=>"file2",5=>"file1"];
natsort($files);
echo json_encode([array_keys($files),array_values($files)]);
Výsledok
[[5,3,7],["file1","file2","file10"]]