0

I have an array like this:

[
        {
            "date": "2019-05-10"
        },
        {
            "date": "2019-05-20"
        },
    ]

I want to convert it to something like this:

['2019-05-10','2019-05-20']

what is the best way to do it in php?

1 Answers1

0

You can use array_reduce

$res = array_reduce($myArray, function($a, $b) {
  $a[] = $b->date;
  return $a;
}, []);
Sergio Rinaudo
  • 2,303
  • 15
  • 20