PHP | ArrayIterator natsort() Function Last Updated : 21 Nov, 2019 Comments Improve Suggest changes Like Article Like Report The ArrayIterator::natsort() function is an inbuilt function in PHP which is used to sort an array naturally. Syntax: void ArrayIterator::natsort( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. Below programs illustrate the ArrayIterator::natsort() function in PHP: Program 1: php <?php // Declare an ArrayIterator $arrItr = new ArrayIterator( array( 5 => 'G', 4 => 'e', 3 => 'E', 2 => 'k', 1 => 'S', ) ); // Sort the array key $arrItr->natsort(); // Display the element while($arrItr->valid()) { echo $arrItr->current() . " "; $arrItr->next(); } ?> Output: E G S e k Program 2: php <?php // Declare an ArrayIterator $arrItr = new ArrayIterator( array("geeks", "GEEKS", "Geeks", "gEEKS") ); // Sort the array with case sensitive $arrItr->natsort(); var_dump($arrItr); ?> Output: object(ArrayIterator)#1 (1) { ["storage":"ArrayIterator":private]=> array(4) { [1]=> string(5) "GEEKS" [2]=> string(5) "Geeks" [3]=> string(5) "gEEKS" [0]=> string(5) "geeks" } } Reference: https://www.php.net/manual/en/arrayiterator.natsort.php Comment More infoAdvertise with us Next Article PHP | ArrayIterator natsort() Function jit_t Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP | ArrayIterator ksort() Function The ArrayIterator::ksort() function is an inbuilt function in PHP which is used to sort the array element by key. Syntax: void ArrayIterator::ksort( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. Below programs illustrate the A 2 min read PHP | ArrayIterator next() Function The ArrayIterator::next() function is an inbuilt function in PHP which is used to move the iterator to the next entry. Syntax: void ArrayIterator::next( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. Below programs illustrate t 1 min read PHP | ArrayIterator offsetSet() Function The ArrayIterator::offsetSet() function is an inbuilt function in PHP which is used to set the value for an offset. Syntax: void ArrayIterator::offsetSet( mixed $index, mixed $newval ) Parameters: This function accepts two parameters as mentioned above and described below: $index: This parameter hol 2 min read PHP | ArrayIterator uasort() Function The ArrayIterator::uasort() function is an inbuilt function in PHP which is used to sort the element using a user-defined comparison function and maintain their index association. Syntax: void ArrayIterator::uasort( callable $cmp_function ) Parameters: This function accepts a single parameter $cmp_f 2 min read PHP | ArrayIterator getFlags() Function The ArrayIterator::getFlags() function is an inbuilt function in PHP which is used to get the behavior of flags of array iterator. Syntax: int ArrayIterator::getFlags( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the behavior flags of the Array 1 min read PHP | ArrayIterator offsetGet() Function The ArrayIterator::offsetGet() function is an inbuilt function in PHP which is used to get the value of an offset. Syntax: mixed ArrayIterator::offsetGet( mixed $index ) Parameters: This function accepts single parameter $index which holds the offset to get the value from. Return Value: This functio 1 min read PHP | ArrayIterator offsetUnset() Function The ArrayIterator::offsetUnset() function is an inbuilt function in PHP which is used to unset the value for an offset. Syntax: void ArrayIterator::offsetUnset( mixed $index ) Parameters: This function accepts single parameter $index which holds the index to unset the offset. Return Value: This func 2 min read PHP | ArrayIterator offsetExists() Function The ArrayIterator::offsetExists() function is an inbuilt function in PHP which is used to check the existence of offset at the given index. Syntax: bool ArrayIterator::offsetExists( mixed $index ) Parameters: This function accepts single parameter $index which holds the index value to check the exis 2 min read ArrayObject natsort() Function in PHP The natsort() function of the ArrayObject class in PHP is used to sort the elements of the ArrayObject following a natural order sorting algorithm. The natsort() function is used to sort alphanumeric strings in a order a normal human being would do. Syntax: void natsort() Parameters: This function d 2 min read PHP | ArrayIterator uksort() Function The ArrayIterator::uksort() function is an inbuilt function in PHP which is used to sort the keys by using a user-defined comparison function. Syntax: void ArrayIterator::uksort( callable $cmp_function ) Parameters: This function accepts single parameter $cmp_function which holds the user defined co 2 min read Like