Web Analytics Made Easy -
StatCounter Can anyone help me? - CodingForum

Announcement

Collapse
No announcement yet.

Can anyone help me?

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

  • Can anyone help me?

    I have a little script I like to use, but im not getting the right use of it

    PHP Code:
    $i 0;
    foreach (
    $replay->Teams as $TeamID=>$Team)
    {
            
    $i++;
            echo 
    "<strong>Team ".$i."</strong><br>\n";
            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') { 
        echo 
    "<img src=\"icons/obs.gif\">".$Player['nick']."<br>\n";


            } 
    Using this script I get

    Team *

    Observers

    Team *

    Players

    Team *

    Players


    ok, but the thing is I wanna get

    Team *

    Players

    Team *

    Players

    Obeservers

    Observers

    HELP!
    Last edited by zPluGGy; Feb 11, 2004, 05:10 PM.

  • #2
    Something along these lines? I simplified the script a bit and kinda guessed the array structure in $replay, as you didn't provide any hint what that's supposed to look like.

    PHP Code:
    $observers = array();
    $i 0;

    foreach (
    $replay->Teams as $TeamID=>$Team) {
        
    $i++;
        echo 
    "<strong>Team ".$i."</strong><br>\n";
        
        foreach (
    $Team as $Player) {
            if (
    $Player['team'] !== 'Observer') { 
                echo 
    $Player['nick']."<br>\n";
            } elseif (
    $Player['team']==='Observer') { 
                
    $observers[] = $Player;            
            }
        }
    }

    for (
    $i 0$i count($observers); $i++) {
        echo 
    "Obs: ".$observers[$i]['nick'] ."<br>\n";

    If this is not the correct sorting order, you need to be more specific in your request. And BTW, you should read the posting guidelines. Your thread subject is not ok.
    De gustibus non est disputandum.

    Comment


    • #3
      OK, nice try but it didn't work

      now it returns

      Team *
      Obs: Name
      Obs: Name
      etc.

      Team*
      Player Name
      Obs: Name
      Obs: Name
      etc.

      Team*
      Player Name
      Obs: Name
      Obs: Name
      etc.

      so all this made was make a additional Obs: Name in all the teams

      Comment


      • #4
        Nice try at not reading my post, because I explicitly stated that I invented a data structure that could fit into your $replay variable. I used this dummy object:

        PHP Code:
        class {
            
            function 
        R(){
                
        $this->Teams = array(
                    
        't1' => array(
                        array(
        'team' => 'Observer',  'nick' => 'Miller'),
                        array(
        'team' => 'Hedgehogs''nick' => 'Gonk'),
                        array(
        'team' => 'Weasels',   'nick' => 'Creel'),
                        array(
        'team' => 'Observer',  'nick' => 'Smitch')

                    ),

                    
        't2' => array(
                        array(
        'team' => 'Observer',  'nick' => 'asdfMiller'),
                        array(
        'team' => 'Hedgehogs''nick' => 'asdfGonk'),
                        array(
        'team' => 'Weasels',      'nick' => 'dsafCreel'),
                        array(
        'team' => 'Observer',  'nick' => 'asdfSmitch')

                    )
                );    
            }

        As you can see, it's all useless dummy data. If you would have told us how the data in $replay is structured, you'd get a much better answer.

        So what is contained in $replay and how is it structured?
        De gustibus non est disputandum.

        Comment

        Working...
        X