PHP nested json into 1-D array

   $data = array();

    

    flatit('',$source);

    

    function flatit($name,$object){

        global $data;

        foreach($object as $key => $value){

            if(is_array($value)){

                flatit($name."_".$key,$value);

            }else{

                 $name = $name."_".$key;

                 echo $name;

                 echo "\n";

                 echo $value;

                 echo "\n";

                $data[substr($name, 1)] = $value;

            }

        }

    }

Comments

Popular posts from this blog

How to Make A Reusable Image Slideshow HTML Component With Vanilla JavaScript

HTML Tags and Inline CSS that Work In Plotly.js Title

How to Type Spaces In HTML Input And Display In the Browser