Manipulating a string??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wlbasile
Forum Newbie
Posts: 1
Joined: Wed Feb 21, 2007 12:28 pm

Manipulating a string??

Post by wlbasile »

I am trying to take a string and firstly:

Spit it back out with no characters other than letters and numbers, and with the first letter of every word capitalized.

Secondly:

Do the same thing as above, but remove all spaces from the string.

I've been advised to use the following functions:

strlen() (Accompanied by a for loop to go through every character)
strpos()
substr()

I am unsure how to set this up. Can anyone help?
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

maybe a regex is the way to go? but they can be somewhat tricky.

http://ca3.php.net/manual/en/function.preg-replace.php
Post Reply