How from this array:
Array
(
[2017-04-10] => 0
[2017-04-11] => 95
[2017-04-12] => 101.67
)
I can get something like this:
$dates = "2017-04-10, 2017-04-11, 2017-04-12";
$price = "0, 95, 101.67";
Thanks.
How from this array:
Array
(
[2017-04-10] => 0
[2017-04-11] => 95
[2017-04-12] => 101.67
)
I can get something like this:
$dates = "2017-04-10, 2017-04-11, 2017-04-12";
$price = "0, 95, 101.67";
Thanks.
Here we are using array_keys , array_values and implode.
1.
array_keysreturn keys of an array2.
array_valuesreturn values of an array3.
implodejoins array witha glue
<?php
ini_set('display_errors', 1);
$array=Array
(
"2017-04-10" => 0,
"2017-04-11" => 95,
"2017-04-12" => 101.67
);
echo $dates=implode(", ", array_keys($array));
echo PHP_EOL;
echo $price=implode(", ", array_values($array));