If you have an array that contains 6 items, including 3 empty strings :
$arr = array('cat1', 'cat2', 'cat3', '', '', '');
You can implode those into a string, this way :
echo '"' . implode('","', $arr) . '"';
And you'll get the following output :
"cat1","cat2","cat3","","",""
Basically, implode allows you to put all items of the array into a string, using a separator -- here, the separator is "," which is what you can between your strings.
And, as implode only put the separator between elements, we have to put an additionnal " at the beginning and at the end of the resulting string.
(Hope I understood what you meant...)
EDIT after the comment :
OK, if your $arr array doesn't contain six items at the beginning :
$arr = array('cat1', 'cat2', 'cat3');
A possibility could be to create an array with empty elements ; like this, for example :
$count = count($arr);
// Create an array with empty elements
$padding = array_fill($count, 6-$count, '');
var_dump($padding);
And, then, add those to the $arr array :
// Add the empty elements to $arr
$arr = $arr + $padding;
(You could also use array_merge, I suppose)
And, now, back to our implode :
echo '"' . implode('","', $arr) . '"';
And, this time again, you'll get :
"cat1","cat2","cat3","","",""
Here's what the var_dump($padding); gives, for information :
array
3 => string '' (length=0)
4 => string '' (length=0)
5 => string '' (length=0)
And, yes, you can use the + operator with arrays (quoting) :
The + operator appends elements of
remaining keys from the right handed
array to the left handed, whereas
duplicated keys are NOT overwritten.
If your $arr could be longer than 6 elements, you could use array_slice to remove the un-wanted elements :
$arr = array('cat1', 'cat2', 'cat3', '', '', '', '');
$arr = array_slice($arr, 0, 6);
echo '"' . implode('","', $arr) . '"';