Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $json = '{"foo":"bar",
- "order":["first", "second", "third"],
- "pairs":[{"id":"0"}, {"id":"1"}]}';
- function doObject($__obj){
- $__obj = cycleObject($__obj);
- return $__obj;
- }
- function cycleObject($__obj){
- foreach($__obj as $key => &$val){
- if(is_object($val)) {
- cycleObject($val);
- }
- if(is_array($val)) {
- foreach($val as &$v) {
- if(is_object($v) || is_array($v)) {
- cycleObject($v);
- } else {
- $v .= '-ok';
- }
- }
- }
- if(is_string($val)) {
- $val .= '-ok';
- }
- }
- return $__obj;
- }
- $obj = doObject(json_decode($json));
- var_dump($obj);
Advertisement
Add Comment
Please, Sign In to add comment