note 103676 added to function.json-encode

From: Date: Wed, 27 Apr 2011 18:07:52 +0000
Subject: note 103676 added to function.json-encode
Groups: php.notes 
Request: Send a blank email to php-notes+get-179204@lists.php.net to get a copy of this message
The function dave wrote works perfectly fine except when the function returns the encoded value has to decrease the recursion depth by one function utf8json($inArray) { static $depth = 0; /* our return object */ $newArray = array(); /* safety recursion limit */ $depth ++; if($depth >= '30') { return false; } /* step through inArray */ foreach($inArray as $key=>$val) { if(is_array($val)) { /* recurse on array elements */ $newArray[$key] = utf8json($val); } else { /* encode string values */ $newArray[$key] = utf8_encode($val); /*the depth is one level up */ if($depth>0) { $depth --; } } } /* return utf8 encoded array */ return $newArray; } ---- Server IP: 69.147.83.197 Probable Submitter: 190.199.2.71 ---- Manual Page -- http://www.php.net/manual/en/function.json-encode.php Edit -- https://master.php.net/note/edit/103676 Del: integrated -- https://master.php.net/note/delete/103676/integrated Del: useless -- https://master.php.net/note/delete/103676/useless Del: bad code -- https://master.php.net/note/delete/103676/bad+code Del: spam -- https://master.php.net/note/delete/103676/spam Del: non-english -- https://master.php.net/note/delete/103676/non-english Del: in docs -- https://master.php.net/note/delete/103676/in+docs Del: other reasons-- https://master.php.net/note/delete/103676 Reject -- https://master.php.net/note/reject/103676 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#179204) next »