I have a form which allows the user to select different categories. Each category has a specific ID number, so a typical response would be:
"10, 7, 15, 46, 32"
and this is stored in the variable $categories.

So I obviously want to split this by the commas, I could use explode() or split() but for this example I'll use explode():
$categories = explode(",", $categories);

Now I want to get rid of the white spaces, so I'll use trim(). But, my question is, can I pass the array $categories into trim() and expect to have the white spaces stripped from each element. Or, will I have to do a while loop, extracting the white space individually from each element.

$c = 0;
$categories[$c] = trim($categories[$c]);