theOptions 配列からいくつかの値を渡して、$theDefaults という新しい配列にドロップしようとしています。
$theOptions = array(
'item1' => array('title'=>'Title 1','attribute'=>'Attribute 1','thing'=>'Thing 1'),
'item2' => array('title'=>'Title 2','attribute'=>'Attribute 2','thing'=>'Thing 2'),
'item3' => array('title'=>'Title 3','attribute'=>'Attribute 3','thing'=>'Thing 3')
);
したがって、$theDefaults 配列は次のようになります。
$theDefaults = array(
'Title 1' => 'Attribute 1',
'Title 2' => 'Attribute 2',
'Title 3' => 'Attribute 3'
);
ただし、これを行う方法がわかりません。これを試してみましたが、明らかにうまくいきません。
$theDefaults = array(); foreach($theOptions as $k=>$v) { array_push($theDefaults, $v['title'], $v['attribute']); }
しかし、これを実行すると...
foreach($theDefaults as $k=>$v) {
echo $k .' :'.$v;
}
これを返します。0 :タイトル 11 :属性 12 :タイトル 23 :属性 24 :タイトル 35 :属性 3
とても近いように見えますが、なぜ配列に数値があるのですか?