Answers for "reduce function in php initial value as array"

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