I have an associative array and I can store its values comma-separated, in a string.
Associative Array has keys
/values
0 => 1
1 => 3
I have tried this
$selected_sizes_comma_seprated = "";
foreach ($selected_sizes as $size) {
$selected_sizes_comma_seprated .= $size.',';
}
// Remove last comma in string
$selected_sizes_comma_seprated = substr($selected_sizes_comma_seprated, 0,-1);
This works fine as I want.
My question is that is there any other better solution to achieve this