Convert data from complex array, with dictionary that is also a complex array

Can you use array_search inside the loop, and will it be quick enough?

$x = array_search($result[$i]['champion'], array_column($dict, 'id'));
$newName = $dict[$x]['name'];
$newTitle = $dict[$x]['title'];

Or, could you arrange $dict[] so that instead of the structure you are using, you have it indexed on the ID column, like

$dict[121]["name"] = "Cianame";
$dict[121]["title"] = "nothingtoseehere";
$dict[122]["name"] = "Shakespeare";
$dict[122]["title"] = "bookclub";

// and then use it directly

$ch = $result[$i]['champion'];
$newName = $dict[$ch].["name"];
$newTitle = $dict[$ch].["title"];
1 Like