PHP 8.5.0 Alpha 1 available for testing

Voting

: max(six, four)?
(Example: nine)

The Note You're Voting On

rattones at gmail dot com
4 years ago
/**
* Convert all values of an array to utf8_encode
* @author Marcelo Ratton
* @version 1.0
*
* @param array $arr array to encode values
* @param bool $keys true to convert keys to UTF8
* @return array same array but with all values encoded to UTF8
*/
function arrayEncodeToUTF8(array $arr, bool $keys= false) : array {
$ret= [];
foreach ($arr as $k=>$v) {
if (is_array($v)) {
$ret[$k]= arrayEncodeToUTF8($v);
} else {
if ($keys) {
$k= utf8_encode((string)$k);
}
$ret[$k]= utf8_encode((string)$v);
}
}

return $ret;
}

<< Back to user notes page

To Top