I want isolate individual values from a flat array of comma-separated values.
I also want to remove any empty strings and duplicated values then sort the result in an ascending fashion.
Sample input:
$cat_ids = [
'9,12',
'5,6,10,13,7,8,14',
'13',
'',
'',
'14',
'15'
];
I have tried this so far,
$cat_ids = array_filter($cat_ids);
$cat_ids = array_map("unserialize", array_unique(array_map("serialize", $cat_ids)));
print_r($cat_ids);
My expected array should be like this,
['5,6,7,8,9,10,12,13,14,15']
OR
[
'5',
'6',
'7',
'8',
'9',
'10',
'12',
'13',
'14',
'15',
];
So it should be easily accessible of any element in this array.