After going through similar questions i couldn't find matching my scenario. I have $artists_temp array like
Array
(
[0] => Array
(
[ID] => 109
[post_title] => Junoon
)
[1] => Array
(
[ID] => 135
[post_title] => Linkin Park
)
)
I have done with code to make the array like
Array
(
[109] => Junoon
[Junoon] =>
[135] => Linkin Park
[Linkin Park] =>
)
Whats required is like
Array
(
[109] => Junoon
[135] => Linkin Park
)
Here is the code
$artists_temp = $wpdb->get_results($query, ARRAY_A);
$artists = array();
foreach ($artists_temp as $key => $value) {
foreach ($value as $k => $v) {
$artists[$v] = next($value);
//unset(next($value)) This doesn't work.
}
}
print_r($artists);
break;on the line after$artists[$v] =.