非常に優れたインデックス付き配列を生成する次のコードがあります-
<?php
// reads csv file and returns an array of rows
function read_csv($filename){
$rows = array();
foreach (file($filename, FILE_IGNORE_NEW_LINES) as $line){
$rows[] = str_getcsv($line, $delimiter = '; ', $escape = '\'');
}
return $rows;
}
?>
出力は次のようになります-
Array
(
[0] => Array
(
[0] => value
[1] => value
[2] => value
[3] => value
[4] => value
[5] => value
[6] => value
[7] => value
[8] => value
[9] => value
[10] => value
[11] => value
[12] => value
[13] => value
[14] => value
[15] => value
[16] => value
[17] => value
[18] => value
[19] => value
[20] => value
)
内部配列のポインタを次のように設定することは可能ですか -
Array
(
[0] => Array
(
[label 1] => value
[label 1] => value
[label 2] => value
[label 3] => value
[label 4] => value
[label 5] => value
[label 6] => value
[label 7] => value
[label 8] => value
[label 9] => value
[label 10] => value
[label 11] => value
[label 12] => value
[label 13] => value
[label 14] => value
[label 15] => value
[label 16] => value
[label 17] => value
[label 18] => value
[label 19] => value
[label 20] => value
)
str_getcsv でこれを行う方法がわかりません。str_getcsv関数の前に配列の要素を定義するかもしれません(これを行う方法がわからない)??? 連想配列に似たものを探しています...