Results 1 to 5 of 5
Thread: Using trim().
Jun 18, 2001, 20:57 #1
- Join Date
- May 2001
- San Diego, CA
- 0 Post(s)
- 0 Thread(s)
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]);
}Ryan Kuhle - A Proud Advisor - Got Questions? Just Ask!
Get your website started for less than $20! Click Here