When you actually use PHP code, you mayThe following code converts PHP Arrays:
- <? Php
- Class arrayiconv
- {
- Static protected $ in;
- Static protected $ out;
- /**
- * Static method. This method inputs an array and returns an array.
- *
- * @ Param unknown_type $ array input array
- * @ Param unknown_type $ encoding of the input Array
- * @ Param unknown_type $ out returns the array encoding.
- * @ Return unknown returned array
- */
- Static public function Conversion ($ array, $ in, $ out)
- {
- Self: $In= $ In;
- Self: $Out= $ Out;
- Return self: arraymyicov ($ array );
- }
- /**
- * Internal method, cyclic Array
- *
- * @ Param unknown_type $ array
- * @ Return unknown
- */
- Static private function arraymyicov ($ array)
- {
- Foreach ($ array as $Key=>$ Value)
- {
- $Key=Self: Myiconv ($ key );
- If (! Is_array ($ value )){
- $Value=Self: Myiconv ($ value );
- } Else {
- $Value=Self: Arraymyicov ($ value );
- }
- $ Temparray [$ key] = $ value;
- }
- Return $ temparray;
- }
- /**
- * Replace array Encoding
- *
- * @ Param unknown_type $ str
- * @ Return unknown
- */
- Static private function myiconv ($ str)
- {
- Return iconv (self ::$ in, self ::$ out, $ str );
- }
- }
- $B=Array("Test" =>Array ("test" =>"Test", "test" =>"Test", "test" =>Array ("test" =>"Test"), "fasdf" =>"Test", "test" =>"Test ");
- $A=Arrayiconv: Conversion ($ B, "UTF-8", "gb2312 ");
- Print_r ($ );
- ?>
The above code is the specific implementation of PHP array conversion, and I hope it will be helpful to friends.