ホームページ >バックエンド開発 >PHPチュートリアル >PHP 配列の分割と結合
ある数グループ:
配列
(
[0] => 15461209
[1] => 12
[2] => 12
[3] => 10 55088
[4] => 1
[5] => 管理者 [6] => 1 [7] => hgtbrshbtyrws [8] [9] => hnrytwsnhbyrtnhb
[10] => 127.0.0.1
[11] => 0 [12] => 0 [13] => 0 [16] => -1
[17] => 0 [18] => 0 [19] => 0 [21] =>
[23] => 0 [24] => 15461210
[26] => 12
=> 1055088
[28] => 0
[29] => ; 管理者
[30] =>
[32] =>
[33] => 11111111111111
[34] => 127.0.0.1
[35] => 0
[36] => 0
[38] => 0
[40] =>
[41] => 0
[42] => 0
[43] => 0
[44] => 0
[45] => 0
[46] => 0
[47] => 0
)
想在变成这种 形式:
配列
(
[0] => 配列
(
[pid] => 15461209
[fid] => 12
[tid] => 1055088
[最初] => 1
[作成者] => 管理者
1
=> hgtbrshbtyrws [日付行] => 1366010391
[メッセージ] => hntyrhnrytwsnhbyrtnhb [useip] => 127.0.0.1 [非表示] => [匿名] => [usesig] =>
[htmlon] => 0
[bbcodeoff] =>
[スマイリーオフ] => -1
[parseurloff] => 0
[添付ファイル] => 0
[レート] => 0
[レートタイム] => 0
[ステータス] => 0
[タグ] =>
[コメント] => 0
)
[1] => 配列
(
[pid] => 15461210
[fid] => 12
[tid] => 1055088
[最初] => 0
[作成者] => 管理者
[作成者ID] => 1
[件名] =>
[日付行] => 1366075840
[メッセージ] => 11111111111111
[useip] => 127.0.0.1
[非表示] => 0
[匿名] =>
[usesig] => 1
[htmlon] => 0
[bbcodeoff] => -1
[スマイリーオフ] = > -1
[parseurloff] => 0
[添付ファイル] => 0
[レート] => 0
[レート時間] => 0
[ステータス] => 0
[タグ] => 0
[コメント] => 0
)
)
写経环、求めたい数組の組み合わせ、これをどのように書きますか? 考慮虑性能问题
http://www.w3school.com.cn/php/php_ ref_array.asp
来,挑戦一个吧
$arr=你的数组..$key=array ( 0 => 'pid', 1 => 'fid', 2 => 'tid', 3 => 'first', 4 => 'author', 5 => 'authorid', 6 => 'subject', 7 => 'dateline', 8 => 'message', 9 => 'useip', 10 => 'invisible', 11 => 'anonymous', 12 => 'usesig', 13 => 'htmlon', 14 => 'bbcodeoff', 15 => 'smileyoff', 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);