Write a PHP script to sort an array using case-insensitive natural ordering

  • برمجة بي اتش بي

Write a PHP script to sort an array using case-insensitive natural ordering

الأجوبة

<?php
$colors = array(
    "color1", "color20", "color3", "color2"
);
sort($colors, SORT_NATURAL | SORT_FLAG_CASE);
foreach ($colors as $key => $val) {
    echo "Colors[" . $key . "] = " . $val . "\n";
}
?>

Sample Output:

Colors[0] = color1                                          
Colors[1] = color2                                          
Colors[2] = color3                                          
Colors[3] = color20
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...