The php array is split and combined with an array:
Array
(
[0] = & gt; 15461209
[1] => 12
[2] => 12
[3] = & gt; 1055088
[4] => 1
[5] => admin
[6] => 1
[7] => hgtbrshbtyrws
[8] = & gt; 1366010391
[9] => hntyrhnrytwsnhbyrtnhb
[10] => 127.0.0.1
[11] => 0
[12] => 0
[13] => 1
[14] => 0
[15] =>-1
[16] =>-1
[17] => 0
[18] => 0
[19] => 0
[20] => 0
[21] => 0
[22] =>
[23] => 0
[24] = & gt; 15461210
[25] => 12
[26] => 12
[27] = & gt; 1055088
[28] => 0
[29] => admin
[30] => 1
[31] =>
[32] = & gt; 1366075840
[33] = & gt; 111111111111111
[34] => 127.0.0.1
[35] => 0
[36] => 0
[37] => 1
[38] => 0
[39] =>-1
[40] =>-1
[41] => 0
[42] => 0
[43] => 0
[44] => 0
[45] => 0
[46] => 0
[47] => 0
)
I want to change it to this form:
Array
(
[0] => Array
(
[Pid] = & gt; 15461209
[Fid] => 12
[Tid] = & gt; 1055088
[First] => 1
[Author] => admin
[Authorid] => 1
[Subject] => hgtbrshbtyrws
[Dateline] = & gt; 1366010391
[Message] => hntyrhnrytwsnhbyrtnhb
[Useip] => 127.0.0.1
[Invisible] => 0
[Anonymous] => 0
[Usesig] => 1
[Htmlon] => 0
[Bbcodeoff] =>-1
[Smileyoff] =>-1
[Parseurloff] => 0
[Attachment] => 0
[Rate] => 0
[Ratetimes] => 0
[Status] => 0
[Tags] =>
[Comment] => 0
)
[1] => Array
(
[Pid] = & gt; 15461210
[Fid] => 12
[Tid] = & gt; 1055088
[First] => 0
[Author] => admin
[Authorid] => 1
[Subject] =>
[Dateline] = & gt; 1366075840
[Message] = & gt; 111111111111111
[Useip] => 127.0.0.1
[Invisible] => 0
[Anonymous] => 0
[Usesig] => 1
[Htmlon] => 0
[Bbcodeoff] =>-1
[Smileyoff] =>-1
[Parseurloff] => 0
[Attachment] => 0
[Rate] => 0
[Ratetimes] => 0
[Status] => 0
[Tags] => 0
[Comment] => 0
)
)
Write a loop and combine the desired array. how can I write it? Performance considerations
Reply to discussion (solution)
Array_chunk + array_combine
Http://www.w3school.com.cn/php/php_ref_array.asp
Come on, pick one.
$ Arr = your array .. $ key = array (0 => 'pid ', 1 => 'fid', 2 => 'tid', 3 => 'first', 4 => 'author ', 5 => 'authorid', 6 => 'subobject', 7 => 'Dateline ', 8 => 'Message', 9 => 'useip ', 10 => 'invisable', 11 => 'anonus us', 12 => 'usesig ', 13 => 'htmlon', 14 => 'bbcodeoff ', 15 => 'sleyoff', 16 => 'parseurloff', 17 => 'attachment ', 18 => 'rate', 19 => 'ratetimes ', 20 => 'status', 21 => 'tags', 22 => 'comment',); foreach (array_chunk ($ arr, 24) as $ v) {array_splice ($ v, 1,1); $ ar [] = array_combine ($ key, $ v);} print_r ($ ar );