I’m using code:
<?php
$fruits = array("1" => "1.jpeg", "2" => "10.jpg", "3" => "11.jpeg", "4" => "12.jpeg", "4" => "2.jpeg");
asort($fruits);
foreach ($fruits as $key => $val) {
echo "$val\n";
}
input:
1.jpeg
10.jpg
11.jpeg
2.jpeg
I want input as
1.jpeg
2.jpeg
10.jpg
11.jpeg
help with me
Also look at: natsort. It does exactly what you want. It even features almost the same sample data.
Output: