I get a multidimensional array from my MySQL database
Array ( [0] => Array ( [page] => categorypropose [value] => baby-sitters [id] => 357960 ) [1] => Array ( [page] => categorysearch [value] => adéquate pour garder [id] => 357961 ) ... )
In this array, I have the conversion of ISO-8859-1 to UTF8, which can be done using the "do-it-yourself" function "loadtext".
But when I do this:
$array = $query->result_array(); foreach($array as &$k) { foreach ($k as &$value) { //Works $value = $this->loadtext($value, 'ISO-8859-1'); } } //Back to normal as $this->loadtext never existed print_r($array);
It does not save the changes (when I return the value of $ value, it works, but the modification is not saved at the end ...)
EDIT: This is the loadtext function that I undertake to use (in fact, I haven't done it, but I have to use it ...)
function loadtext($text,$charset){ $text = stripslashes($text); if($charset!="UTF-8") $text = iconv("UTF-8",$charset,$text); $text = str_replace(" :"," :",$text); $text = str_replace(" ;"," ;",$text); $text = str_replace(" !"," !",$text); $text = str_replace(" ?"," ?",$text); $text = str_replace(" ."," .",$text); $text = str_replace(" …"," …",$text); return $text; }