Replacing individual characters in a variable...

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

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

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
Contact:

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..

Xerpher
New php-forum User
New php-forum User
Posts: 164
Joined: Tue Aug 27, 2002 8:25 pm
Location: Ontario, Canada
Contact:

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

Just curious, you using ereg/preg match or some function or loop you made yourself?

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

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.. :)

azteck
New php-forum User
New php-forum User
Posts: 12
Joined: Sun Dec 15, 2002 3:54 pm

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

I guess using str_replace('+',' ',$item) should do.


Return to “PHP coding => General”

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 0 guests