Posts

Showing posts with the label multidimensional-array

Take parts of two separate arrays and combine them into one

Take parts of two separate arrays and combine them into one I have two arrays. Each of them consist of "date" and "close" keys. Example: Array1 - Date: 12-Jun-18, Close: "55.6" Array2 - Date: 12-Jun-18, Close: "1.26" $stock_one_prices = sw::shared()->prices->getForStockID($id); $stock_one_prices_array = array(); foreach ($stock_one_prices as $stock_one_price) { $stock_one_prices_array = [ "date" => $stock_one_price['date'], "close" => $stock_one_price['close'] ]; } $stock_two_prices = sw::shared()->prices->getForStockID($idtwo); $stock_two_prices_array = array(); foreach ($stock_two_prices as $stock_two_price) { $stock_two_prices_array = [ "date" => $stock_two_price['date'], "close" => $stock_two_price['close'] ]; } I would like to take the two arrays and combine them into one, matching the dates of the ...