If you don't talk much about it, go directly to the Code:
<? PHP /************************************** * ************************ use a specific function to process all elements in the array * @ Param string & $ array the string to be processed * @ Param string $ function the function to be executed * @ return Boolean $ apply_to_keys_also is also applied to the key * @ access public ******* **************************************** * *************/function arrayrecursive (& $ array, $ function, $ apply_to_keys_also = false) {static $ recursive_counter = 0; If (++ $ Recursive_counter> 1000) {die ('possible deep recursion attack');} foreach ($ array as $ key => $ value) {If (is_array ($ value )) {arrayrecursive ($ array [$ key], $ function, $ apply_to_keys_also);} else {$ array [$ key] = $ function ($ value );} if ($ apply_to_keys_also & is_string ($ key) {$ new_key = $ function ($ key); if ($ new_key! = $ Key) {$ array [$ new_key] = $ array [$ key]; unset ($ array [$ key]) ;}}$ recursive_counter --;} /*************************************** * ************************ convert an array to a JSON string (compatible with Chinese characters) * @ Param array $ array the array to be converted * @ return string the converted JSON string * @ access public ***************** **************************************** * ***/function JSON ($ array) {arrayrecursive ($ array, 'urlencode', true); $ JSON = json_e Ncode ($ array); Return urldecode ($ JSON);} $ arr = array (Array ('id' => '0 ', 'name' => 'my name', 'title' => 'resolve JSON resolution'), array ('id' => '1 ', 'name' => 'my name', 'title' => 'Resolution JSON resolution'); echo JSON ($ ARR);?>