sort an array values alphabetically in PHP

sort an array values alphabetically in PHP

In this post we will give you information about sort an array values alphabetically in PHP. Hear we will give you detail about sort an array values alphabetically in PHPAnd how to use it also give you demo for it if it is necessary.

Use the PHP sort() and rsort() function


The PHP sort() and rsort() functions can be used for sorting numeric or indexed arrays. The following sections will show you how these functions basically work:


Sorting Numeric Arrays in Ascending Order


You can use the sort() function for sorting the numeric array elements or values alphabetically or numerically in the ascending order. Let’s try out an example to see how it works:



<?php
$text = array("Sky", "Cloud", "Birds", "Rainbow", "Moon");
$numbers = array(1, 2, 3.5, 5, 8, 10);
 
// Sorting the array of string
sort($text);
print_r($text);
echo "<br>";
 
// Sorting the array of numbers
sort($numbers);
print_r($numbers);
?>


 

Hope this and post will helped you for implement sort an array values alphabetically in PHP. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

  +  76  =  86

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US