array:5 [▼
"open" => "info"
"on_hold" => "warning"
"answered" => "success"
"dev. In progress" => "success"
"closed" => "default"
];
I need to use this array and get only the index to String like this
'ticket_statuses' => [
'open' => 'info',
'on_hold' => 'warning',
'answered' => 'success',
'dev. In progress' => 'success',
'closed' => 'default',
]
$array = config('settings.ticket_statuses');
$status = implode(',', $array);
dd($status);
When i using implode($array) result look like this
"info,warning,success,success,default"
But I don't need this
CodePudding user response:
If you only want to implode the indexes, think you mean open
, on_hold
, you need to use the array_keys()
method:
$array = [
'open' => 'info',
'on_hold' => 'warning'
];
echo implode(',', array_keys($array)); // echo: open,on_hold