我怎樣才能把這種陣列相結合:如何三個陣列與[0]作爲鑰匙插入一個
Array ([0] => 80) Array ([0] => 20) Array ([0] => 90)
到這樣的陣列:
Array (
[0] => 80,
[1] => 20,
[2] => 90
);
代碼:
$percentage_result = $percentage_query->result_array(); //output below:
輸出:
Array
(
[0] => Array
(
[id] => 62
[list_id] => 55
[start_date] => 1459987200
[end_date] => 1459987200
[percentage] => 80
)
[1] => Array
(
[id] => 64
[list_id] => 55
[start_date] => 1459814400
[end_date] => 1459814400
[percentage] => 20
)
[2] => Array
(
[id] => 63
[list_id] => 55
[start_date] => 1459900800
[end_date] => 1459900800
[percentage] => 90
)
我想保存所有[百分比]並獲得最高的一個。
這樣做:
$null = array();
foreach ($percentage_result as $ptime) {
//Days between start date and end date -> seasonal price
$start_time = $ptime['start_date'];
$end_time = $ptime['end_date'];
$percentage_sm = explode(',', $ptime['percentage']);
$mrg = array_merge($null, $percentage_sm);
print_r($mrg);
$味精顯示我:
Array
(
[0] => 80
)
Array
(
[0] => 20
)
Array
(
[0] => 90
)
我們e array_merge –
[array_merge()](http://www.php.net/manual/en/function.array-merge.php)也許....嘗試看看PHP文檔....他們可以是非常有幫助 –
@SunilPachlangia它不起作用。 –