Functionarray_iconv ($ in_charset, $ out_charset, $ arr) {& amp; nbsp; returneval (& amp; #39; return & amp; #39 ;. iconv ($ in_charset, $ out_charset, var_export ($ arr, true ). & amp; #39; & amp; #39;); & amp; nbsp ;}copy the code principle analysis... function array_iconv ($ in_charset, $ out_charset, $ arr) {return eval ('call '. iconv ($ in_charset, $ out_charset, var_export ($ arr, true ). ';');} principle analysis: var_export sets the second parameter to true. Back to the array prototype string, convert the string to UTF-8 encoding, and then use eval to execute and return (similar to anonymous functions ?), This is a perfect solution. Later: most of the methods found on the Internet use recursive calling of iconv. if there are too many array elements or a large number of dimensions, the performance will be poor. the better is the native code method, no need to consider whether it is an n-dimensional array or an associated array. everything has been completed automatically to ensure data consistency before and after array conversion. Slave code length
1. Detailed introduction to array encoding
Introduction: php array conversion function example. Scenario/problem description: the Ajax submission page is encoded as gb2312 and the database code is utf8. data is inserted without changing the page and database code. UDF: the code is as follows:
10. php array encoding conversion method
Introduction: php array encoding conversion method
[Related Q & A recommendations ]:
Javascript-localstorage method for storing object arrays
Algorithm-a python question: How to dictionary tuples?
The above is the details of 10 articles recommended for group Editing. For more information, see other related articles in the first PHP community!