Replace value in a string

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Eric

    Replace value in a string

    Hi !
    I want to replace 'xxx' with '12' (for example) in a string $chaine. How can I do ?
    Thanks for your answers
    Eric
  • Geoff Berrow

    #2
    Re: Replace value in a string

    I noticed that Message-ID:
    <ac562571.03102 90457.74ec9e8e@ posting.google. com> from Eric contained
    the following:
    [color=blue]
    >I want to replace 'xxx' with '12' (for example) in a string $chaine. How can I do ?
    >Thanks for your answers[/color]

    str_replace("xx x","12",$chaine )

    --
    Geoff Berrow
    It's only Usenet, no one dies.
    My opinions, not the committee's, mine.
    Simple RFDs http://www.ckdog.co.uk/rfdmaker/

    Comment

    • Pedro

      #3
      Re: Replace value in a string

      Geoff Berrow wrote:[color=blue]
      > Eric[color=green]
      >>I want to replace 'xxx' with '12' (for example) in a string $chaine. How can I do ?[/color]
      >
      > str_replace("xx x","12",$chaine )[/color]

      better make that an assignment:

      $chaine = str_replace('xx x', '12', $chaine);

      --
      I have a spam filter working.
      To mail me include "urkxvq" (with or without the quotes)
      in the subject line, or your mail will be ruthlessly discarded.

      Comment

      • Peter Tselios

        #4
        Re: Replace value in a string

        Eric wrote:
        [color=blue]
        > Hi !
        > I want to replace 'xxx' with '12' (for example) in a string $chaine. How
        > can I do ? Thanks for your answers
        > Eric[/color]
        try phpdoc. there you will find that you can do that with
        $chaine=str_rep lace("xxx", "12", $chaine)

        --
        ==============
        Peter Tselios

        Comment

        • Geoff Berrow

          #5
          Re: Replace value in a string

          I noticed that Message-ID:
          <bnoep6$13npve$ 1@ID-203069.news.uni-berlin.de> from Pedro contained the
          following:
          [color=blue]
          >better make that an assignment:[/color]

          Got leave him something to do. ;-)

          --
          Geoff Berrow
          It's only Usenet, no one dies.
          My opinions, not the committee's, mine.
          Simple RFDs http://www.ckdog.co.uk/rfdmaker/

          Comment

          • Alan Little

            #6
            Re: Replace value in a string

            Carved in mystic runes upon the very living rock, the last words of Eric
            of comp.lang.php make plain:
            [color=blue]
            > I want to replace 'xxx' with '12' (for example) in a string $chaine.
            > How can I do ? Thanks for your answers[/color]



            --
            Alan Little
            Phorm PHP Form Processor

            Comment

            Working...