I have an array object like this:
Array
(
[0] => stdClass Object
(
[id] => 1
[name] => sam
)
[1] => stdClass Object
(
[id] => 2
[name] => tim
)
[2] => stdClass Object
(
[id] => 3
[name] => nic
)
)
And I want to have this:
Array
(
[sam] => sample text
[tim] => sample text
[nic] => sample text
)
My current approach:
$arr = array();
foreach($multi_arr as $single_arr) {
$arr[$single_arr->name] = "sample text";
}
Is there a cleaner/better approach than this? Thanks
json_decode()?static_textthen merely callingarray_column($resultSet, 'static_text', 'name')?