chainmatrix
-
Posts
3 -
Joined
-
Last visited
Never
Posts posted by chainmatrix
-
-
Just change the variable name to $value. It will overwrite the current value in the loop.
Thank you for the answer. However, that does not seem to update the original values in the array; after running through the loop, they remain unchanged?
-
Situation is as follows: I have fetched data from database. This data has all special characters replaced with their ASCII value codes (ä is ä , ö is ö and so on). Due to the encoding, data is not in correct alphabetical order after fetching it; thus I'd need to decode all the characters back into normal UTF-8 characters and then sort the data. html_entity_decode seems to handle this. However, I am unable to figure out how to decode the data, as it is currently located in a multidimensional array?
I started solving this by going through the arrays with loops; my current code is below, but my knowledge in arrays in not good enough to figure out how to replace the data within the array with the decoded values?
foreach ($result_array as $row) { foreach ($row as $key => $value) { $new_value = html_entity_decode($value); // I would now need to replace the original $value in $result_array with the $new_value, but can't figure out how to do it?? } }
Decoding ASCII value encoded characters into UTF-8 characters inside an array?
in PHP Coding Help
Posted
For some reason I could still not get it work, original values in the array remained unchanged. However, inspired by your first suggestion I was able to decode the offending characters already when creating the array from database search result. Looked like this:
(The next step was to figure out how to sort the multidimensional array. Just in case someone googles this up, below is also an example of how to do it -- it may well be piece of cake to the brainiacs among us, but it took me quite a while to figure out. )
Thank you for your help Zanus, much appreciated!