By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,720 Members | 2,185 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,720 IT Pros & Developers. It's quick & easy.

Replace a character in a string variable

P: n/a
Syl
Hi group -

I have a variable which is created from an input form.
After concatenating the input I want, I end up with a variable named
$all which looks like this :
delegatecountry,delegatefname,delegatelname,delega tebname

I want to take this string and replace all the commas with this :
</th><th>

So - I tried this :

$inside="</th><th>";
$newall = str_replace($inside, ",", $all);
But - it doesn't work.
http://ca3.php.net/str_replace

What am I doing wrong ?

Jun 30 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
ED

"Syl" <da**********@gmail.com> wrote in message
news:11**********************@x69g2000cwx.googlegr oups.com...
Hi group -

I have a variable which is created from an input form.
After concatenating the input I want, I end up with a variable named
$all which looks like this :
delegatecountry,delegatefname,delegatelname,delega tebname

I want to take this string and replace all the commas with this :
</th><th>

So - I tried this :

$inside="</th><th>";
$newall = str_replace($inside, ",", $all);
But - it doesn't work.
http://ca3.php.net/str_replace

What am I doing wrong ?


First 2 parameters the wrong way round, should be:

$newall = str_replace(',', $inside, $all);

cheers
ED
Jun 30 '06 #2

P: n/a
Syl

ED wrote:
"Syl" <da**********@gmail.com> wrote in message
news:11**********************@x69g2000cwx.googlegr oups.com...
Hi group -

I have a variable which is created from an input form.
After concatenating the input I want, I end up with a variable named
$all which looks like this :
delegatecountry,delegatefname,delegatelname,delega tebname

I want to take this string and replace all the commas with this :
</th><th>

So - I tried this :

$inside="</th><th>";
$newall = str_replace($inside, ",", $all);
But - it doesn't work.
http://ca3.php.net/str_replace

What am I doing wrong ?


First 2 parameters the wrong way round, should be:

$newall = str_replace(',', $inside, $all);

cheers
ED


DOH!

Thanks very much ED for the quick reply!

Jun 30 '06 #3

P: n/a
ED

"Syl" <da**********@gmail.com> wrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...

ED wrote:
"Syl" <da**********@gmail.com> wrote in message
news:11**********************@x69g2000cwx.googlegr oups.com...
> Hi group -
>
> I have a variable which is created from an input form.
> After concatenating the input I want, I end up with a variable named
> $all which looks like this :
> delegatecountry,delegatefname,delegatelname,delega tebname
>
> I want to take this string and replace all the commas with this :
> </th><th>
>
> So - I tried this :
>
> $inside="</th><th>";
> $newall = str_replace($inside, ",", $all);
>
>
> But - it doesn't work.
> http://ca3.php.net/str_replace
>
> What am I doing wrong ?
>


First 2 parameters the wrong way round, should be:

$newall = str_replace(',', $inside, $all);

cheers
ED


DOH!

Thanks very much ED for the quick reply!


:) no prob!
Jun 30 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.