473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Replace a character in a string variable

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
3 21951
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: K.Simon | last post by:
Hello, it's very often neccessary to replace strings or a single character in my stylesheets. My solution looks awful and very long. Now i thought to solve this with an array like structure but...
1
by: Billy N. Patton | last post by:
-------- Original Message -------- Subject: <string>.replace Date: Fri, 15 Oct 2004 11:07:19 -0500 From: Billy N. Patton <b-patton@ti.com> Organization: Texas Instruments Newsgroups:...
8
by: Eric Lilja | last post by:
Hello, I had what I thought was normal text-file and I needed to locate a string matching a certain pattern in that file and, if found, replace that string. I thought this would be simple but I had...
19
by: Paul | last post by:
hi, there, for example, char *mystr="##this is##a examp#le"; I want to replace all the "##" in mystr with "****". How can I do this? I checked all the string functions in C, but did not...
5
by: Mahesha | last post by:
Hello, I need help in replacing one string pattern with another. Ex: I have a financial security expression like log(T 3.25 6/24/2004)/sqrt(T 4.5 6/19/2002) Here "T 3.25 6/24/2004" is a...
14
by: Etu | last post by:
Hi, I have a string: string c = "'abc' \"cde\", 'mno' \"xyz\","; how can I use the c.Replace(???, ???) method to have this string: "'abc' "cde", 'mno' "xyz"," that is, all the...
3
by: Craig Buchanan | last post by:
Is there a way to combine these two Replace into a single line? Regex.Replace(Subject, "\&", "&amp;") Regex.Replace(Subject, "\'", "&apos;") Perhaps Regex.Replace(Subject, "{\&|\'}", "{&amp;|&apos;}")...
4
by: serge | last post by:
I managed to put together C# code and have it do the following: 1- Get all the table names that start with the letter "Z" from sysobjects of my SQL 2000 database and put these table names...
6
by: kilik3000 | last post by:
How do you do a global replace in a string without using a regex? For example, "ABBA".replace("B", "") returns -"ABA" // I'd like this to be a global replace "ABBA".replace(/B/g, "") ...
10
by: Lonifasiko | last post by:
Hi, Just want to replace character at index 1 of a string with another character. Just want to replace character at that position. I thought Replace method would be overloaded with an index...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.