Web Analytics Made Easy -
StatCounter help using str_replace or something that works - CodingForum

Announcement

Collapse
No announcement yet.

help using str_replace or something that works

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • help using str_replace or something that works

    Ok, I can explain so some pplz understand me and some people won't
    So here it goes

    Is there any way I can use str replace so if text comes

    "<strong>Team 1</strong><br>
    <br>"

    It replaces it with nothing
    but if the text

    "<strong>Team 1</strong><br>
    Playername"

    Comes, It doesn't do anything to it, so here's the code that shows Team *... blabla

    PHP Code:
    foreach ($replay->Teams as $TeamID=>$Team) {
        
    $i++;

    $thing "<strong>Team ".$i."</strong><br>\n";
    print 
    $thing;
        foreach (
    $Team as $Player) {
            if (
    $Player['team'] !== 'Observer') { 
                echo 
    "    <img src=\"big/".$Player[color]."/".$Player['race'].".jpg\" height=50>".$Player['nick']."<br>\n";
            } elseif (
    $Player['team']==='Observer') { 
                
    $observers[] = $Player;                  
        }
    }echo 
    "<br>\n";



  • #2
    I'm not exactly sure what you mean...


    PHP Code:
    $thing="<strong>Team 1</strong><br><br>";
    $finds "/<strong>(.*)<br><br>/is";
    $returned preg_replace($finds,"",$thing);

    print 
    $thing// doesn't print anything 

    Comment


    • #3
      I think I understand your question, but I don't see how your code reflects your question.

      It prints off the first line, but it doesn't print Playername on the next. It either prints off a picture and then the player's nickname and a <br>, or nothing (elseif).

      Are you referring to the case where the $Team array is empty, and so only that final <br> is printed? In that case, I would do the following:

      PHP Code:
      if(sizeof($Team) != 0) {
       print 
      $thing;
       .
       .
       .
       echo 
      "<br>\n";

      I'm also not sure about your use of double and triple equal signs...

      Let me know if that's not what you mean.
      Sadiq.

      Comment

      Working...
      X