Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<mb_convert_kanamb_decode_mimeheader>
^Multibyte String FunctionsLast updated: Mon, 26 Oct 2026

mb_convert_variables

(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)

mb_convert_variables — Convert character code in variable(s)

Description

function mb_convert_variables(
    string $to_encoding,
    array|string $from_encoding,
    mixed &$var,
    mixed &...$vars
): string|false

Converts character encoding of variables var and vars in encoding from_encoding to encoding to_encoding.

mb_convert_variables() join strings in Array or Object to detect encoding, since encoding detection tends to fail for short strings. Therefore, it is impossible to mix encoding in single array or object.

Parameters

to_encoding

The encoding that the string is being converted to.

from_encoding

The current encoding of the variables. Multiple encodings may be specified as an array or comma separated string, in which case the encoding is detected among the listed encodings. "auto" is expanded according to the mbstring.language INI setting.

var

var is the reference to the variable being converted. String, Array and Object are accepted. mb_convert_variables() assumes all parameters have the same encoding.

vars

Additional vars.

Return Values

The character encoding before conversion for success, or false for failure.

Examples

Example #1 mb_convert_variables() example

<?php
/* Convert variables $post1, $post2 to internal encoding */
$interenc = mb_internal_encoding();
$inputenc = mb_convert_variables($interenc, "ASCII,UTF-8,SJIS-win", $post1, $post2);
?>


<mb_convert_kanamb_decode_mimeheader>
^Multibyte String FunctionsLast updated: Mon, 26 Oct 2026