PHP mb_detect_order() Function Last Updated : 28 Apr, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The mb_detect_order() function is an inbuilt function in PHP that is utilized to set or get the character encoding detection order. Syntax: mb_detect_order(array|string|null $encoding = null): array|bool Parameters: This function has only one parameter. encoding: This parameter returns the current character encoding detection order as an array if the encoding is omitted or null. Return Value: This function returns true when setting encoding detection order otherwise it will return false. Example 1: The following code demonstrates the mb_detect_order() function. PHP <?php // Set detection order mb_detect_order("UTF-8, ASCII"); // Use mb_detect_encoding() to detect // encoding of string $string = "GeeksforGeeks"; $encoding = mb_detect_encoding($string); // Output encoding echo "Detected encoding: $encoding"; ?> Output: Detected encoding: UTF-8 Example 2: The following code demonstrates the mb_detect_order() function. PHP <?php /* Set detection order by enumerated list */ mb_detect_order("eucjp-win,sjis-win,UTF-8"); /* Set detection order by array */ $ary[] = "ASCII"; $ary[] = "JIS"; $ary[] = "EUC-JP"; mb_detect_order($ary); /* Display current detection order */ echo implode(", ", mb_detect_order()); ?> Output: ASCII, JIS, EUC-JP Reference: https://www.php.net/manual/en/function.mb-detect-order.php Comment More infoAdvertise with us Next Article PHP | DsSet sorted() Function N neeraj3304 Follow Improve Article Tags : PHP PHP-function PHP-Multibyte-String Similar Reads ArrayObject ksort() Function in PHP The ksort() function of the ArrayObject class in PHP is used to sort the elements of the ArrayObject according to the keys. This function does not affects the association of the keys with the values, it just sorts the entries of the ArrayObject according to the Keys. Syntax: void ksort() Parameters: 2 min read ArrayObject ksort() Function in PHP The ksort() function of the ArrayObject class in PHP is used to sort the elements of the ArrayObject according to the keys. This function does not affects the association of the keys with the values, it just sorts the entries of the ArrayObject according to the Keys. Syntax: void ksort() Parameters: 2 min read PHP krsort() Function The krsort() function is an inbuilt function in PHP which is used to sort an array by key in reverse order according to its index values. It sorts in a way that relation between indices and values is maintained. Syntax: bool krsort( $array, $sorting_type ) Parameters: This function accepts two param 2 min read PHP krsort() Function The krsort() function is an inbuilt function in PHP which is used to sort an array by key in reverse order according to its index values. It sorts in a way that relation between indices and values is maintained. Syntax: bool krsort( $array, $sorting_type ) Parameters: This function accepts two param 2 min read PHP | DsSet sorted() Function The Ds\Set::sorted() function is an inbuilt function in PHP which is used to return a sorted copy of given set. Syntax: Ds\Set public Ds\Set::sorted ([ callable $comparator ]) Parameters: This function accepts a comparator function according to which the values will be compared while sorting the Set 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 Like