if help

Discussion in 'PHP' started by crazyryan, Dec 5, 2006.

  1. #1
    I have this:

        if (empty($comment['username']))
        {
            $comment['username'] = 'Unknown';
        }
        $comments .= $tpl->pull_template ('comment');
    
    PHP:
    Basically, I want it so if the username = admin, replace admin with <u>admin</u>,

    can anyone help?
     
    crazyryan, Dec 5, 2006 IP
  2. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #2
    preg_replace("/".$comment['username']."/si", "<u>".$comment['username']."</u>", $pagadata);

    dunno what pagedata is, but that gives you the idea
     
    krakjoe, Dec 5, 2006 IP
  3. crazyryan

    crazyryan Well-Known Member

    Messages:
    3,087
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    175
    #3
    thanks but i had a mess around with that code and couldn't get it working
     
    crazyryan, Dec 5, 2006 IP
  4. CodyRo

    CodyRo Peon

    Messages:
    365
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #4
    In the code you posted I think you may be missing some information that could aid us in helping you.. but from the sound of it why not just make a simple if statement?

    
    if (empty($comment['username']))
        {
            if ($comment['username'] = "admin") {
    
               $comment['username'] = "<em>admin</em>";
    
            } else {
    
            $comment['username'] = 'Unknown';
    
           }
        }
        $comments .= $tpl->pull_template ('comment');
    
    PHP:
    Unless you want it for any user who is a admin and not just the username "admin".
     
    CodyRo, Dec 5, 2006 IP
  5. crazyryan

    crazyryan Well-Known Member

    Messages:
    3,087
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    175
    #5
    That's why I asked for if help, I suck at PHP. I done that and got an unexpected $end on line something so added another } but that didn't show the comments.
     
    crazyryan, Dec 5, 2006 IP