So I am writing a script that uses ids to hide certain content. However, my javascript has a tendency not to work whenever my IDs have spaces in them. So I want to remove all the spaces in the IDs like lets say I have the words "Tele Skis" I want to break that into "TeleSkis" with minimal effort. I cannot just specify the variables to have no whitespace since they are coming from a database.
Thanks for any help
If it's only spaces you're concerned with:
echo str_replace(' ', '', $id);
If it could be any white-space (space, tab, newline):
echo preg_replace('/\s/', '', $id);