Answers for "php array reduce return"

1

array reduce associative array php

$assoc_arr = array_reduce($arr, function ($result, $item) {
    $result[$item['text']] = $item['id'];
    return $result;
}, array());
Posted by: Guest on June-18-2021

Browse Popular Code Answers by Language