我会创建这样的
$dataPoints = array(
array(
'point' => 1,
'price' => 1.5,
'country' => 'UK'
),
array(
'point' => 1,
'price' => 1.3,
'country' => 'US'
),
array(
'point' => 1,
'price' => .8,
'country' => 'SWEDEN'
),
...
)
阵列而像
function getPrice($pricePoint, $country) {
// Search in array for good price
foreach ($dataPoints as $dataPoint) {
if ($dataPoint['point'] == $pricePoint && $dataPoint['country'] == $country) {
return $dataPoint['price'];
}
}
return null;
}
一个功能,与你的讯息参数称它为打印
$pp = filter_input(INPUT_POST, 'price_point');
$country = filter_input(INPUT_POST, 'country_name');
$price = getPrice($pp,$country);
echo 'Country is ', $country, '. The price point is ', $pp, '. The price is ', $price;
阅读PHPexcel阅读和写入Excel表。否则,您将需要使用像mysql这样的数据库(并将phpmyadmin作为MySQL的gui)并查询它是最佳方式。使用phpexcel,您可以将电子表格导入到数组或对象中,使用php进行修改并将其导出。 – Nitin
您需要使用数组的索引进行最快搜索$ arr = array('US'=> [...],'UK'=> [...]);或根据搜索参数动态重新排列阵列 – Nitin