Case-insensitive str_replace

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • -= Patrick =-

    Case-insensitive str_replace

    Hi,
    I'm trying to replace strings in a body of html. These strings may
    contain spaces. str_replace works perfectly, except that it is
    case-sensitive. I've tried using eregi_replace, but I think there is
    something wrong with my regex's. Here is my current code:

    $bword may contain something like: "testing testing 123"

    $bword = trim ($bword); //Remove trailing newlines
    str_replace (' ', '[\s]', $bword); //Change spaces to [\s]
    $urlhtml = eregi_replace ("[\s]($bword)[\s]", $replacecode, $urlhtml);

    It seems to pick up some words, but not all......
  • Andy Hassall

    #2
    Re: Case-insensitive str_replace

    On Wed, 06 Aug 2003 13:21:13 GMT, "Ian.H [dS]" <ian@WINDOZEdig iserv.net> wrote:
    [color=blue]
    >What's wrong with str_ireplace() ?[/color]



    str_ireplace
    (PHP 5 CVS only)

    That's what ;-p

    --
    Andy Hassall (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
    Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

    Comment

    • Ian.H [dS]

      #3
      Re: Case-insensitive str_replace

      -----BEGIN PGP SIGNED MESSAGE-----
      Hash: SHA1

      Whilst lounging around on Wed, 06 Aug 2003 19:29:31 +0100, Andy
      Hassall <andy@andyh.co. uk> amazingly managed to produce the following
      with their Etch-A-Sketch:
      [color=blue]
      > On Wed, 06 Aug 2003 13:21:13 GMT, "Ian.H [dS]"
      > <ian@WINDOZEdig iserv.net> wrote:
      >[color=green]
      > >What's wrong with str_ireplace() ?[/color]
      >
      > http://uk2.php.net/str_ireplace
      >
      > str_ireplace
      > (PHP 5 CVS only)
      >
      > That's what ;-p[/color]


      lol.. that'll teach me eh? =)



      Regards,

      Ian

      -----BEGIN PGP SIGNATURE-----
      Version: PGP 8.0

      iQA/AwUBPzFdMmfqtj2 51CDhEQL8NwCgsB lFBpgbiZyozP9vm tjz4wx1vNEAnjFE
      VBfacKyiROMH3B5 EDnwe0MDa
      =vHAT
      -----END PGP SIGNATURE-----

      --
      Ian.H [Design & Development]
      digiServ Network - Web solutions
      www.digiserv.net | irc.digiserv.ne t | forum.digiserv. net
      Programming, Web design, development & hosting.

      Comment

      Working...