This function is powerful. it is much more powerful than the built-in functions in php. This function can automatically obtain your character encoding and convert it to the encoding you want based on your reference, the code is as follows:
This function is powerful. it is much more powerful than the built-in functions in php. This function can automatically obtain your character encoding and convert it to the encoding you want based on your reference, the code is as follows:
- /**
- * Implement transcoding in a loop
- *
- * @ Param string $ param (string, object, or array), $ currCharset current encoding, $ toCharset expected encoding
- * @ Return parameter type
- */
- Function zhandi_iconv ($ param, $ currCharset, $ toCharset ){
- If ($ currCharset! = $ ToCharset ){
- If (is_string ($ param )){
- Return iconv ($ currCharset, $ toCharset, $ param );
- }
- Elseif (is_array ($ param )){
- Foreach ($ param as $ key => $ value ){
- $ Param [$ key] = zhandi_iconv ($ value );
- }
- Return $ param;
- }
- Elseif (is_object ($ param )){
- Foreach ($ param as $ key => $ value ){
- $ Param-> $ key = zhandi_iconv ($ value );
- }
- Return $ param;
- }
- Else {
- Return $ param;
- }
- }
- Return $ param;
- }