Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Mar 2005
    Posts
    735
    Thanks
    4
    Thanked 1 Time in 1 Post

    highlighting problem: shouldn't highlight one letter at a time

    What's wrong with this:
    PHP Code:
    for($m=0$m <  count($bigWords); $m++){
            
    $strText preg_replace("/(".$keyword[$m].")/i""<span class=\"\" id=\"\" style=\"color:".$COLORS[$m].";                             font-weight:bold;\">$1</span>"$strText);
            echo 
    "<br />";
            echo 
    $strText;
        } 
    It's highlighting one letter at a time:
    Code:
    <span class="" id="" style="color:red; font-weight:bold;"></span>
    t<span class="" id="" style="color:red; font-weight:bold;"></span>
    h<span class="" id="" style="color:red; font-weight:bold;"></span>
    e<span class="" id="" style="color:red; font-weight:bold;"></span>
     <span class="" id="" style="color:red; font-weight:bold;"></span>
    w<span class="" id="" style="color:red; font-weight:bold;"></span>
    h<span class="" id="" style="color:red; font-weight:bold;"></span>
    o<span class="" id="" style="color:red; font-weight:bold;"></span>
    
     <span class="" id="" style="color:red; font-weight:bold;"></span>
    a<span class="" id="" style="color:red; font-weight:bold;"></span>
    n<span class="" id="" style="color:red; font-weight:bold;"></span>
    d<span class="" id="" style="color:red; font-weight:bold;"></span>
     <span class="" id="" style="color:red; font-weight:bold;"></span>
    b<span class="" id="" style="color:red; font-weight:bold;"></span>
    u<span class="" id="" style="color:red; font-weight:bold;"></span>
    Last edited by gilgalbiblewhee; 07-31-2008 at 02:50 AM.
    Compare bible texts (and other tools):
    TheWheelofGod

  • #2
    Regular Coder Apothem's Avatar
    Join Date
    Mar 2008
    Posts
    380
    Thanks
    36
    Thanked 25 Times in 25 Posts
    $strText = preg_replace("/(".$keyword[$m].")/i", "<span class=\"\" id=\"\" style=\"color:".$COLORS[$m].";

    Question: Why doesn't the preg_replace have it's matching parenthesis? Also, where does $keyword derive from? What is in it, to be exact.

  • #3
    Regular Coder
    Join Date
    Mar 2005
    Posts
    735
    Thanks
    4
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Pykex View Post
    $strText = preg_replace("/(".$keyword[$m].")/i", "<span class=\"\" id=\"\" style=\"color:".$COLORS[$m].";

    Question: Why doesn't the preg_replace have it's matching parenthesis? Also, where does $keyword derive from? What is in it, to be exact.
    Oh yeah. Actually the semicolon is part of the style attribute:
    PHP Code:
    $strText preg_replace("/(".$keyword[$m].")/i""<span class=\"\" id=\"\" style=\"color:".$COLORS[$m]."; font-weight:bold;\">$1</span>\n"$strText); 
    You had some good questions. $keyword was not in the code this part was pasted but I forgot to change it. It should be:
    PHP Code:
    $strText $searchThese;
        for(
    $m=0$m <  count($bigWords); $m++){
            
    $strText preg_replace("/(".$bigWords[$m].")/i""<span class=\"\" id=\"\" style=\"color:".$COLORS[$m]."; font-weight:bold;\">$1</span>\n"$strText);
            echo 
    "<br />\n";
            echo 
    $strText;
        } 
    But this is causing a repetition:
    the who and but Moses flock Jethro father priest Midian flock backside desert mountain Horeb angel appeared flame midst looked behold burned consumed Moses aside great sight burnt
    the who and but Moses flock Jethro father priest Midian flock backside desert mountain Horeb angel appeared flame midst looked behold burned consumed Moses aside great sight burnt
    the who and but Moses flock Jethro father priest Midian flock backside desert mountain Horeb angel appeared flame midst looked behold burned consumed Moses aside great sight burnt
    the who and but Moses flock Jethro father priest Midian flock backside desert mountain Horeb angel appeared flame midst looked behold burned consumed Moses aside great sight burnt
    the who and but Moses flock Jethro father priest Midian flock backside desert mountain Horeb angel appeared flame midst looked behold burned consumed Moses aside great sight burnt
    the who and but Moses flock Jethro father priest Midian flock backside desert mountain Horeb angel appeared flame midst looked behold burned consumed Moses aside great sight burnt
    the who and but Moses flock Jethro father priest Midian flock backside desert mountain Horeb angel appeared flame midst looked behold burned consumed Moses aside great sight burnt
    the who and but Moses flock Jethro father priest Midian flock backside desert mountain Horeb angel appeared flame midst looked behold burned consumed Moses aside great sight burnt
    the who and but Moses flock Jethro father priest Midian flock backside desert mountain Horeb angel appeared flame midst looked behold burned consumed Moses aside great sight burnt
    the who and but Moses flock Jethro father priest Midian flock backside desert mountain Horeb angel appeared flame midst looked behold burned consumed Moses aside great sight burnt
    the who and but Moses flock Jethro father priest Midian flock backside desert mountain Horeb angel appeared flame midst looked behold burned consumed Moses aside great sight burnt
    the who and but Moses flock Jethro father priest Midian flock backside desert mountain Horeb angel appeared flame midst looked behold burned consumed Moses aside great sight burnt
    the who and but Moses flock Jethro father priest Midian flock backside desert mountain Horeb angel appeared flame midst looked behold burned consumed Moses aside great sight burnt
    the who and but Moses flock Jethro father priest Midian flock backside desert mountain Horeb angel appeared flame midst looked behold burned consumed Moses aside great sight burnt
    the who and but Moses flock Jethro father priest Midian flock backside desert mountain Horeb angel appeared flame midst looked behold burned consumed Moses aside great sight burnt
    the who and but Moses flock Jethro father priest Midian flock backside desert mountain Horeb angel appeared flame midst looked behold burned consumed Moses aside great sight burnt
    the who and but Moses flock Jethro father priest Midian flock backside desert mountain Horeb angel appeared flame midst looked behold burned consumed Moses aside great sight burnt
    the who and but Moses flock Jethro father priest Midian flock backside desert mountain Horeb angel appeared flame midst looked behold burned consumed Moses aside great sight burnt
    the who and but Moses flock Jethro father priest Midian flock backside desert mountain Horeb angel appeared flame midst looked behold burned consumed Moses aside great sight burnt
    the who and but Moses flock Jethro father priest Midian flock backside desert mountain Horeb angel appeared flame midst looked behold burned consumed Moses aside great sight burnt
    the who and but Moses flock Jethro father priest Midian flock backside desert mountain Horeb angel appeared flame midst looked behold burned consumed Moses aside great sight burnt
    the who and but Moses flock Jethro father priest Midian flock backside desert mountain Horeb angel appeared flame midst looked behold burned consumed Moses aside great sight burnt
    The first Highlights only one word and the last highlights all that it should.
    Compare bible texts (and other tools):
    TheWheelofGod


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •