Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Replacing individual characters in a variable...

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Replacing individual characters in a variable...

Postby WRStrong » Wed Mar 05, 2003 10:04 am

I have a good one... I think..

How would one scan a variable say:

$ItemName = ("This Name");

and change it to $ItemName = ("This+Name");

and make it dynamic so that no matter what the $ItemName is, it would change any space to a plus sign.

Thanks,

Bill Strong
WRStrong
New php-forum User
New php-forum User
 
Posts: 24
Joined: Wed Mar 05, 2003 9:52 am
Location: Bellefonte, PA

Postby WRStrong » Wed Mar 05, 2003 10:49 am

Nevermind... after tons of tries... I found a work-around. I had some coding screwed up & it originally didn't understand the plus symbol... now it does..
WRStrong
New php-forum User
New php-forum User
 
Posts: 24
Joined: Wed Mar 05, 2003 9:52 am
Location: Bellefonte, PA

Postby Xerpher » Wed Mar 05, 2003 1:59 pm

Just curious, you using ereg/preg match or some function or loop you made yourself?
Xerpher
New php-forum User
New php-forum User
 
Posts: 164
Joined: Tue Aug 27, 2002 8:25 pm
Location: Ontario, Canada

Postby WRStrong » Wed Mar 05, 2003 2:08 pm

Neither. The actual item that is using the output had the ability to handle the conversion of the space to a plus symbol. I just had to change some settings.. :)
WRStrong
New php-forum User
New php-forum User
 
Posts: 24
Joined: Wed Mar 05, 2003 9:52 am
Location: Bellefonte, PA

Postby azteck » Thu Mar 06, 2003 12:16 pm

I guess using str_replace('+',' ',$item) should do.
azteck
New php-forum User
New php-forum User
 
Posts: 12
Joined: Sun Dec 15, 2002 3:54 pm


Return to PHP coding => General

Who is online

Users browsing this forum: TurnitinBot [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.