PHP setlocale() Function

PHP setlocale() Function

The setlocale() function in PHP sets locale information(language, monetary, time and, other information specific for a geographical area.)

Syntax

setlocale ( int $category , array $locale )

Parameter

category(required)- This parameter specified a named constant specifying the category of the functions affected by the locale setting. The constant list is as follow:

  • LC_ALL-  all of the below
  • LC_COLLATE- for string comparison
  • LC_CTYPE- for character classification and conversion
  • LC_MONETARY- for localeconv()
  • LC_NUMERIC- for decimal separator
  • LC_TIME- for date and time formatting with strftime()
  • LC_MESSAGES- for system responses

location(required)- This parameter specifies what country or region to set the locale information(string or an array). It is also possible to pass multiple locations.

Return

This function returns the new current locale, or FALSE if the specified locale functionality is not implemented on your platform, or if the locale does not exist or the category name is invalid.

Example 1

 

Output

The setlocale() function will return: en_US.UTF-8

Example 2

 

Output

The category LC_MESSAGES return: en_US.UTF-8
The category LC_CTYPE return: 

Example 3

 

Output

The setlocale() function will return: 

Related Topics

PHP array_key_last() function

The array_key_last () function in PHP gets the last key of an array if the specified array is not empty. Syntax array_key_last ( array $array )  Parameter array(required)- This parameter signifies the input array. Return This function returns the last key of the...

1 minute read.

PHP str_getcsv() Function

PHP str_getcsv() Function The str_getcsv() function in PHP parses a CSV string into an array and returns an array containing the fields read. Syntax str_getcsv ( string $input [, string $delimiter [, string $enclosure [, string$escape ]]] ) Parameter input(required)- This parameter represents the string to parse. delimiter(optional)- This parameter signifies...

1 minute read.

PHP uasort() Function

PHP uasort() Function The uasort() function in PHP sorts an array with a user-defined comparison function and maintains the index association. Syntax uasort ( array &$array , callable $value_compare_func ) Parameter array(required)- This parameter represents the input array. value_compare_func(required)- This parameter represents a string that describe a...

1 minute read.

PHP intval() Function

The intval() Function in PHP is used to get the integer value for the given variable. This function should not be used on objects. Else it will emit an E_NOTICE level error and return 1. Syntax intval...

1 minute read.

PHP is_scalar() Function

PHP is_scalar() Function The is_scalar() function in PHP finds whether a variable is a scalar or not. It returns a Boolean value TRUE if the parameter var is scalar, else it returns FALSE. Scalar variables are those containing an integer, float, string or boolean. This...

1 minute read.

PHP empty() Function

PHP empty() Function The empty() function in PHP determines whether the specified variable is empty or not. The specified variable is considered empty if it does not exist or if its value is equal to FALSE. This function...

1 minute read.

PHP Example

We can create a simple program by writing the source code inside the php tag and save it with .php extension. Syntax: <?php // your code here ?> Let us take an example of PHP. <!DOCTYPE html> <html> <head>            ...

1 minute read.

PHP array_fill_keys() Function

The array_fill_keys() function in PHP fills an array with the value of the specified value parameter, using the values of the specified keys array as keys. Syntax array_fill_keys ( array $keys , mixed $value ) Parameter keys(required)- This parameter signifies the input array of values that will be...

1 minute read.

PHP array_sum() Function

PHP array_sum() Function The array_sum() function in PHP is used to calculate the sum of values in an array. Syntax array_sum ( array $array ) Parameter array(required)- This array represents the input array. Return This function returns the sum of values as an...

1 minute read.

PHP quoted_printable_encode() Function

PHP quoted_printable_encode() Function The quoted_printable_encode() function in PHP converts a 8 bit string to a quoted-printable string. This function is similar to imap_8bit(), except this one does not require the IMAP module to work. Syntax quoted_printable_encode ( string $str ) Parameter str(required)- This parameter represents...

1 minute read.

PHP array_diff_assoc() Function

PHP array_diff_assoc() Function The array_diff_assoc() Function in PHP compares the difference of arrays and returns an array containing all the values from array1 that are not present in any of the other arrays. Syntax array_diff_assoc ( array $array1 , array $array2 [, array $... ] ) Parameter array1(required)- This parameter signifies...

1 minute read.

PHP next() Function

PHP next() Function The next() function in PHP advances or moves the internal array pointer one place forward and returns the next array value. Syntax next ( array &$array ) Parameter array(required)- This parameter represents the input array. Return This parameter returns the next array value...

1 minute read.

PHP is_string() Function

PHP is_string() Function The is_ string() function in PHP finds whether a variable is a string or not. It returns a Boolean value TRUE if the parameter var is string, else it returns FALSE. Syntax is_string ( mixed $var ) Parameter var(required)- This parameter represents...

1 minute read.

PHP array_udiff_assoc() Function

PHP array_udiff_assoc() Function The array_udiff_assoc () function in PHP computes the difference between the specified arrays with additional index check and compares the data by a callback function. It returns all the values from array1 that are not...

1 minute read.

PHP array_product() Function

PHP array_product() Function The array_product() function in PHP calculates the product of values in an array. Syntax array_product ( array $array ) Parameter array(required)- This parameter represents the input array. Return This function returns the product of the array elements as an integer or float....

1 minute read.

PHP vsprintf() Function

PHP vsprintf() Function The vsprintf() function in PHP returns a formatted string. This function accepts an array of arguments. Syntax vsprintf ( string $format , array $args ) Parameter format(required)- This parameter specifies the string and how to format the variables in it. The conversion specification of this parameter...

3 minutes read.

PHP in_array() Function

PHP in_array() Function The in_array() function in PHP checks if the value exists in the specified array or not. Syntax in_array ( mixed $needle , array $haystack [, bool $strict = FALSE ] )  Parameter needle(required)- This parameter represents the searched value. haystack(required)- This parameter represents the input array. strict(optional)- This parameter...

1 minute read.

PHP is_double() Function

The PHP is_double() function in PHP is used to  find whether the type of the specified variable is a float or not. It returns a Boolean value true if the parameter var is...

1 minute read.

PHP trim() Function

PHP trim() Function The trim() Function in PHP strips the whitespace or other characters from the beginning and the end of the given string. The trim() function strips the following characters: " " - an ordinary space."\t"- a tab."\n"- a new...

1 minute read.

PHP asort() function

PHP asort() function The asort() function in PHP is used to sort an array while maintaining the index association. Syntax asort ( array &$array [, int $sort_flags = SORT_REGULAR ] )  array(required)- This parameter represents the input array to sort. sort_flags (optional)- This parameter is used to...

1 minute read.