I have an array that I have JSON decoded from a JSON object. Below is my array I am using for select options. The problem is each select options has a option group with a number (0-11). How can I convert this array to one that does not have these numbers in front of it?
Here is my array:
array(21) { [0]=> array(1) { [198413]=> string(23) "option1" } [1]=> array(1) { [247598]=> string(24) "option2" } [2]=> array(1) { [195666]=> string(17) "option3" } [3]=> array(1) { [195632]=> string(22) "option..." } [4]=> array(1) { [243763]=> string(24) "option..." } [5]=> array(1) { [196600]=> string(13) "option..." } [6]=> array(1) { [196597]=> string(11) "option..." } [7]=> array(1) { [196592]=> string(16) "option..." } [8]=> array(1) { [196549]=> string(17) "option..." } [9]=> array(1) { [251324]=> string(10) "option..." } [10]=> array(1) { [195564]=> string(50) "option..." } }
Here is my code:
$result = drupal_http_request('https://'.$key.'@'.$company.'.example.com/example.json');
$feed_array = json_decode($result->data, TRUE);
$projects = array();
foreach ($feed_array['todo-lists'] as $project) {
$projects[] = array(
$project['id'] => $project['name']
);
}