How to use php and jquery to product multilevel json structure : i want to product an output like the below, but i dont know how to do it, any help?

    {  
       "messages":[  
          {  
             "from":"InfoSMS",
             "to":[  
                "41793026727",
                "41793026731"
             ],
             "text":"May the Force be with you!"
          },
          {  
             "from":"41793026700",
             "to":"41793026785",
             "text":"A long time ago, in a galaxy far, far away... It is a period of civil war. Rebel spaceships, striking from a hidden base, have won their first victory against the evil Galactic Empire."
          }
       ]
    }