Re: Replace a character in a string variable




ED wrote:
"Syl" <david.hunter@xxxxxxxxx> wrote in message
news:1151679331.062036.128540@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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,delegatebname

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!

.



Relevant Pages

  • Re: Replace a character in a string variable
    ... I have a variable which is created from an input form. ... After concatenating the input I want, I end up with a variable named ... First 2 parameters the wrong way round, ... :) no prob! ...
    (comp.lang.php)
  • Re: Replace a character in a string variable
    ... I have a variable which is created from an input form. ... After concatenating the input I want, I end up with a variable named ... I want to take this string and replace all the commas with this: ... First 2 parameters the wrong way round, ...
    (comp.lang.php)
  • Replace a character in a string variable
    ... I have a variable which is created from an input form. ... After concatenating the input I want, I end up with a variable named ... I want to take this string and replace all the commas with this: ...
    (comp.lang.php)
  • Inputing data to 3 tables from one input form
    ... I am trying to update 3 tables from one input form, ... I have tried to get round it by joining 2 querys ... Is it possible to place a sub form onto a tab page, ...
    (microsoft.public.access.gettingstarted)