我在Google工作表中包含以下数据:
我用简单的代码从Google驱动器中提取它:
$ranges = [
'Price_1'
];
$params = array(
'ranges' => $ranges
);
$response = $service->spreadsheets_values->batchGet($spreadsheetId, $params);
和:
for($i = 1; $i < 5; $i++) {
print_r ($response->getValueRanges()[0]['values'][$i]);
}
给出: Array ( [0] => 01A [1] => adult ( 12+ ) [2] => Catamaran [3] => 2h [4] => 28 ) Array ( [0] => 01B [1] => child ( age 5-11 ) [2] => Catamaran [3] => 2h [4] => 14 ) Array ( [0] => 01C [1] => toodler ( age 0-4) [2] => Catamaran [3] => 2h [4] => 0 ) Array ( )
结果,我需要一个简单的数组,该数组将保存一个key [row id],来自ID行的ID和来自最后一行的价格,如下所示: $result[$i] = unique_id=1, ID=01A, price=28
如何实现?
MYYA