I have an API that sends me the data in the format
[{"part_no":"AAA"},{"part_no":"BBB"},{"part_no":"CCC"},......{"part_no":"ZZZ"}]
I want to create an array like ["AAA", "BBB", ...., "ZZZ"] from the above array.
I know it's possible by iterating the array item by item, and appending it to a new array, but thought that there might be a better (and hopefully faster) approach.
Like C# hasLinq that does this all in a one-liner, JS has map, it is possible to do a similar thing in PHP ?
$out = array_map(fn($item) => $item['part_no'], $in);or, if it's a simple associative array:$out = array_column($in, 'part_no');$out = array_map(function ($part) { return $part['part_no']; }, json_decode($data, true));7.2, and your code returnsnull$data?