WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Mobile Dev World
Detect character encoding

mb_detect_encoding

(PHP 4 >= 4.0.6, PHP 5)

mb_detect_encodingDetect character encoding

Description

string mb_detect_encoding ( string $str [, mixed $encoding_list= mb_detect_order() [, bool $strict= false ]] )

Detects character encoding in string str .

Parameters

str

The string being detected.

encoding_list

encoding_list is list of character encoding. Encoding order may be specified by array or comma separated list string.

If encoding_list is omitted, detect_order is used.

strict

strict specifies whether to use the strict encoding detection or not. Default is FALSE.

Return Values

The detected character encoding.

Examples

Example #1 mb_detect_encoding() example

<?php
/* Detect character encoding with current detect_order */
echo mb_detect_encoding($str);

/* "auto" is expanded to "ASCII,JIS,UTF-8,EUC-JP,SJIS" */
echo mb_detect_encoding($str"auto");

/* Specify encoding_list character encoding by comma separated list */
echo mb_detect_encoding($str"JIS, eucjp-win, sjis-win");

/* Use array to specify encoding_list  */
$ary[] = "ASCII";
$ary[] = "JIS";
$ary[] = "EUC-JP";
echo 
mb_detect_encoding($str$ary);
?>

See Also


Dynamic WHERE CLAUSE depending on number of FORM FIELDS
Categories : ODBC, General SQL, PHP, Complete Programs, Databases
color codes for positive and negative numbers
Categories : PHP, MySQL, Databases, HTML
How to count the number of lines in a file
Categories : PHP, Filesystem



Function get_week_number which returns the week number of the given date according to ISO 8601:1988, also includes a function is_leap_year.
Categories : Date Time, PHP
Creates three SELECT form fields: Month, Day, and Year. You give it a string which will be used to make the name for the three fields, and a number of seconds to use as the default date. If you give it blank for this value, the current date is used.
Categories : HTML and PHP, PHP, Date Time
Dollar Serial Number Validator
Categories : PHP, Security, Algorithms
Permutations, Combinations and Factorials
Categories : PHP, PHP Classes, Math.
Banknote Validation - A PHP class that provides several methods to quickly validate banknote serial numbers of the following currencies: AUD, CAD, CHF, CNY, EUR, GBP, JPY, USD.
Categories : PHP, PHP Classes, Data Validation, Regexps
Embedding you tube videos in your site with PHP and MySQL
Categories : PHP, MySQL, Databases
convert a number (three digits) to written form (English & Spanish)
Categories : PHP, Algorithms
Counting the number of lines in a file
Categories : PHP, Filesystem
This function returns a random string of a specified number of digits without leading zeros. For example, if three digits are specified, the function will return a random three-digit number from 100 to 999.
Categories : Algorithms, PHP
Numbers to words
Categories : PHP, PHP Classes
This provides a drop down form for searching with different search engines. All the encoding/arguments are set by the program as need for each supported search engine (currently 18)
Categories : HTML, Search