PHP Conference Kansai 2025

Voting

: min(one, nine)?
(Example: nine)

The Note You're Voting On

rogeriogirodo at gmail dot com
16 years ago
This function may be useful do encode array keys and values [and checks first to see if it's already in UTF format]:

<?php
public static function to_utf8($in)
{
if (
is_array($in)) {
foreach (
$in as $key => $value) {
$out[to_utf8($key)] = to_utf8($value);
}
} elseif(
is_string($in)) {
if(
mb_detect_encoding($in) != "UTF-8")
return
utf8_encode($in);
else
return
$in;
} else {
return
$in;
}
return
$out;
}
?>

Hope this may help.

[NOTE BY danbrown AT php DOT net: Original function written by (cmyk777 AT gmail DOT com) on 28-JAN-09.]

<< Back to user notes page

To Top