php - Looping through the arrays -


this original code

    [width] => array         (             [0] => 400px             [1] => 323a         )      [height] => array         (             [0] => 244px             [1] => 244px         )      [captions] => array         (             [0] => [{ "captionid": 1,"caption": "learning clock face fun - learn importance of time.","xycordinates": "40px-250px","dimension": "70%-20%"},{"captionid": 2,"caption": "12 or 12 pm","xycordinates": "40px-250px","dimension": "70%-20%"}]             [1] => [{ "captionid": 1,"caption": "learning clock face fun - learn importance of time.","xycordinates": "40px-250px","dimension": "70%-20%"},{"captionid": 2,"caption": "12 or 12 pm","xycordinates": "40px-250px","dimension": "70%-20%"}]         ) ) 

the above code actual code, need loop code looks similar 1 below. please me out.

the page id keeps incrementing. please me out

"pages": [     {       "pageid": "1",       "resource": {         "width": "220px",         "height": "120px",         "captions": [           {             "captionid": 1,             "caption": "learning alphabets fun - learn eat.",             "xycordinates": "40px-250px",             "dimension": "70%-20%"           }         ]       },       "pageorder": 1,       "state": 1     }] 

first have format data in structure want in php , @ end have encode json.. might have read data in array , create model classes , encode json

json_encode() 

sample code

$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);  echo json_encode($arr); 

the out put {"a":1,"b":2,"c":3,"d":4,"e":5}


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -