Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

PHP: multibyte function to get string length (See related posts)

	/**
	 * Get string length, multibyte.
	 *
	 * @param   string  $t Any string content
	 * @param   string  $encoding Charset encoding
	 * @return  int     String length
	 */
	function mb_strlen($t, $encoding = 'UTF-8')
	{
		/* --enable-mbstring */
		if (function_exists('mb_strlen'))
		{
			return mb_strlen($t, $encoding);
		}
		else
		{
			return strlen(utf8_decode($t));
		}
	}

You need to create an account or log in to post comments to this site.


Click here to browse all 4857 code snippets

Related Posts