Loading ...
Sorry, an error occurred while loading the content.

Re: Problem: Search Result

Expand Messages
  • Hasin Hayder
    Hi if u looked at the manual first, u wil get the solution. str_replace is the case sensitive version and str_ireplace is teh case in-sensitive version. so you
    Message 1 of 6 , Aug 29, 2005
    • 0 Attachment
      Hi

      if u looked at the manual first, u wil get the solution.

      str_replace is the case sensitive version

      and str_ireplace is teh case in-sensitive version. so you have to use
      str_ireplace()

      Thanks
      --Hasin

      --- In phpexperts@yahoogroups.com, Anisuzzaman
      <anisuzzaman_rasel@y...> wrote:
      >
      > But the main problem is .. if
      >
      >
      >
      > $str_to_highlight = "RED";
      >
      >
      >
      > and
      >
      >
      >
      > $text = "Red Hot Chili Pepers ar www.redhat.com";
      >
      >
      >
      > then it will never work, cause.. It's in different case (Red and RED)..
      >
      >
      >
      > Then? what will be the better solution... ???
      >
      >
      >
      >
      >
      > - Anisuzzaman
      >
      >
      >
      > Hasin Hayder <augustwind16@y...> wrote:
      > Hi,
      >
      > dont use ereg or preg functiosn until u exclusively need those, cause
      > they are resource hungry.
      >
      > use the follwoing function
      >
      > <?
      > $str_to_highlight = "Red";
      > $str_highlighted = "<b>{$str_to_highlight}</b>";
      >
      > $text = "Red Hot Chili Pepers ar www.redhat.com";
      >
      > $highlighted_text = str_replace($str_to_highlight,$str_highlighted,
      > $text);
      >
      > echo $highlighted_text;
      > ?>
      >
      > Thanks
      > --Hasin
      > http://hasin.phpxperts.com
      > --- In phpexperts@yahoogroups.com, Anisuzzaman
      > <anisuzzaman_rasel@y...> wrote:
      > >
      > > How can I mark a word/Sentence that is given in for Search purpose?
      > >
      > >
      > >
      > > Say, I want to search "red" in google.com. After matching, it shows
      > result like this..
      > >
      > >
      > >
      > > Red Hat | The Open Source Leader
      > > Official site; news, support, documentation, whitepapers, downloads,
      > consulting,
      > > training, embedded solutions.
      > > www.redhat.com/ - 12k - 27 Aug 2005 - Cached - Similar pages
      > >
      > >
      > >
      > > Where "red" is in bold letter, as well as not in, case sensitive.
      > >
      > >
      > >
      > > How can I do this or which php function can solve my problem?
      > >
      > >
      > >
      > > Thanks you..
      > >
      > >
      > >
      > >
      > >
      > >
      > >
      > > - Anisuzzaman
      > >
      > >
      > > __________________________________________________
      > > Do You Yahoo!?
      > > Tired of spam? Yahoo! Mail has the best spam protection around
      > > http://mail.yahoo.com
      > > __________________________________________________
      > > Do You Yahoo!?
      > > Tired of spam? Yahoo! Mail has the best spam protection around
      > > http://mail.yahoo.com
      >
      >
      >
      >
      >
      >
      > Visit ProjectsHosted, online directory for PHP software :
      http://dev6.php5.nedlinux.com
      >
      >
      >
      > SPONSORED LINKS
      > Basic programming language Computer programming languages Knowledge
      base system Programming languages Knowledge base solution Knowledge
      base management
      >
      > ---------------------------------
      > YAHOO! GROUPS LINKS
      >
      >
      > Visit your group "phpexperts" on the web.
      >
      > To unsubscribe from this group, send an email to:
      > phpexperts-unsubscribe@yahoogroups.com
      >
      > Your use of Yahoo! Groups is subject to the Yahoo! Terms of
      Service.
      >
      >
      > ---------------------------------
      >
      >
      >
      >
      > __________________________________________________
      > Do You Yahoo!?
      > Tired of spam? Yahoo! Mail has the best spam protection around
      > http://mail.yahoo.com
    • Hasin Hayder
      HI, here is the solution as u need
      Message 2 of 6 , Aug 29, 2005
      • 0 Attachment
        HI,

        here is the solution as u need


        <?
        $text = "Red Hot Chili Pepers ar www.redhat.com";

        $str_to_highlight = "~(red)~i";

        $str_highlight_pattern = "<b>\${1}\</b>";

        $final_highlighted = preg_replace($str_to_highlight,
        $str_highlight_pattern , $text);

        echo $final_highlighted ;
        ?>


        --Hasin
      Your message has been successfully submitted and would be delivered to recipients shortly.