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 ArrayObject ksort() Function in PHP N neeraj3304 Follow Improve Article Tags : PHP PHP-function PHP-Multibyte-String Similar Reads PHP DsQueue peek() Function The Ds\Queue::peek() Function in PHP is used to get the value present at the front of a Queue. This function simply returns the element present at the front of a Queue instance without actually removing it. Syntax: mixed public Ds\Queue::peek ( void ) Parameters: This function does not accepts any p 2 min read PHP key_âexists() Function The key_exists() function is an inbuilt function in PHP that is used to check whether the given key exist in the given array or not. If given key exist in the array then it returns true otherwise returns false. This function is an alias of array_key_exists() function. Syntax: bool key_exists(string| 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 | DsVector sorted() Function The Ds\Vector::sorted() function is an inbuilt function in PHP which is used to sort the elements of the vector by creating a copy of the original vector. This will arrange the vector elements in increasing order using default comparator. Syntax: Ds\Vector public Ds\Vector::sorted( $comparator ) Par 2 min read PHP DsQueue isEmpty() Function The Ds\Queue::isEmpty() Function in PHP is used to whether a particular Queue instance is empty or not. It returns True if the Queue is empty otherwise it returns False. Syntax: bool public Ds\Queue::isEmpty ( void ) Parameters: This function does not accepts any parameters. Return Value: This funct 1 min read Like