Php array reorganization help this post was last edited by suifengmin at 13:46:33
What I get now is:
The first array:
Array ([0] => Array ([themes] => default/skin/index.swf [name] => test [logo] => http://6.com/upload_files/article/2/1_20131217101219_mvnun.jpg [x] => 485 [y] => 260 [w] => 26 [h] => 34 [createdate] => 2013-12-17 [diedate] => 2013-12-02 ))
The second array is a loop:
Array ([0] => Array ([name] => admin [lock] => 1 [time] => 1970-01-01 [gift] => img/ae77500803b347fe9986d838b7a5fff3.png [gname] => test 1 [gid] => 1 [x] => 150 [y] => 150 [w] => 150 [valid tive] => 3 [dtime] => 1970-01-01) [1] => Array ([name] => admin [lock] => [time] => 1970-01-01 [gift] => img/ae77500803b450fe9986d838b7a5fff3.png [gname] => test 2 [gid] => 1 [x] => 150 [y] => 150 [w] => 150 [valid tive] => 3 [dtime] => ))
Combined into the following
Array ([0] => Array ([themes] => img/101228180517877.swf [name] => Mingming [logo] => img/20121102142618.jpg [x] => 485 [y] => 260 [w] => 26 [h] => 34 [createdate] => 2013-12-12 [diedate] => 2013-12-12 [itme] => Array ([0] => Array ([0] => Array ([0] => Array ([name] => 123 [lock] => false [time] => 12:10:40 [gift] => img /ae77500803b450fe9986d838b7a5fff3.png [gname] => Beautiful permanent [gid] => hh0 [x] => 100 [y] => 100 [w] => 100 [h] => 100 [valid tive] => 3 days [dtime] => 12:10:40 )) [1] => Array ([0] => Array ([name] => bj [lock] => true [time] => 12:10:40 [gift] => img/ ae77500803b450fe9986d838b7a5fff3.png [gname] => Happy Health [gid] => hh1 [x] => 200 [y] => 200 [w] => 150 [h] => 150 [valid tive] => 3 days [dtime] => 12:10:40 )) [2] => Array ([0] => Array ([name] => Our World [lock] => true [time] => 12:10:40 [gift] => img/ae77500803b450fe9986d838b7a5fff3.png [gname] => Beautiful permanent [gid] => hh2 [x] => 300 [y] => 300 [w] => 400 [h] => 400 [valid tive] => 3 days [dtime] => 12:10:40 ))))))
Reply to discussion (solution)
You can assign values directly without knowing that the operators do not match your application.
$ A = array ('themes' => 'default/skin/index.swf ', 'name' => 'test', 'logo' =>' http://6.com/upload_files/article/2/1_20131217101219_mvnun.jpg ', 'X' => 485, 'y' => 260, 'W' => 26, 'H' => 34, 'createdate' =>, 'diddate' => 2013-12-02),); $ B = array ('name' => 'admin', 'lock' => 1, 'Time' => 1970-01-01, 'giput' => 'IMG/ae77500803b450fe9986d838b7a5fff3.png ', 'gname' => 'test 1', 'gid' => 1, 'x' => 150, 'y' => 150, 'W' => 150, 'effect' => 3, 'dtime' =>), array ('name' => 'admin ', 'lock' => '', 'Time' => 1970-01-01, 'giput' => 'IMG/ae77500803b450fe9986d838b7a5fff3.png ', 'gname' => 'test 2 ', 'gid' => 1, 'x' => 150, 'y' => 150, 'W' => 150, 'negative last' => 3, 'dtime' => 1970-01-01); $ a [0] ['itme'] = $ B; print_r ($ );
Thanks to the answers provided by the upstairs, an array is missing.
In fact, the final format required for converting to json is:
[{
"Themes": "img/101228180517877.swf ",
"Name": "Mingming ",
"Logo": "img/20121102142618.jpg ",
"X":" 485 ",
"Y": "260 ",
"W": "26 ",
"H": "34 ",
"Createdate": "2013-12-12 ",
"Diedate": "2013-12-12 ",
"Itme ":[{
"0 ":[{
"Name": "123 ",
"Lock": "false ",
"Time": "12:10:40 ",
"Gift": "img/ae77500803b450fe9986d838b7a5fff3.png ",
"Gname": "Beautiful permanent ",
"Gid": "hh0 ",
"X":" 100 ",
"Y": "100 ",
"W": "100 ",
"H": "100 ",
"Valid tive": "3 Days ",
"Dtime": "12:10:40"
}],
"1 ":[{
"Name": "bj ",
"Lock": "true ",
"Time": "12:10:40 ",
"Gift": "img/ae77500803b450fe9986d838b7a5fff3.png ",
"Gname": "happy and healthy ",
"Gid": "hh1 ",
"X":" 200 ",
"Y": "200 ",
"W": "150 ",
"H": "150 ",
"Valid tive": "3 Days ",
"Dtime": "12:10:40"
}],
"2 ":[{
"Name": "Our World ",
"Lock": "true ",
"Time": "12:10:40 ",
"Gift": "img/ae77500803b450fe9986d838b7a5fff3.png ",
"Gname": "Beautiful permanent ",
"Gid": "hh2 ",
"X":" 300 ",
"Y": "300 ",
"W": "400 ",
"H": "400 ",
"Valid tive": "3 Days ",
"Dtime": "12:10:40"
}]
}]
}]
Thank you for writing the above information as prompted.