Convertir a UTF-8 (arreglo u objeto) PHP

Por admin-dayscript, 10 Abril, 2017

Funcion recursiva

function array_to_utf($array = array()){ foreach ( $array as $key => $value ) { if(is_array($value)){ $temp[$key] = self::array_to_utf($value); }elseif(is_object($value)){ foreach ($value as $index => $item) { $temp[$key][$index] = utf8_encode(html_entity_decode($item, ENT_QUOTES | ENT_HTML401, "UTF-8")); } } else{ $temp[$key] = utf8_encode(html_entity_decode($value,ENT_QUOTES | ENT_HTML401, "UTF-8")); } } return $temp; }

Comentarios