Is there an easy way to implode an array of enums ?
enum Fruits: string{
case APPLE = 'apple';
case PEAR = 'pear';
case ORANGE = 'orange';
}
/*
* @param array<Fruits>|null $fruits
*/
function setInDB ( ... $fruits ... ){
...
$str_fruits = implode( ',' $fruits );
...
}
My code above makes this PHP error :
Error: Object of class Fruits could not be converted to string
Is there a way to resolve this without make a loop, get enum value and concatenate in string ?