Will this work??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Todlerone
Forum Commoner
Posts: 96
Joined: Sun Oct 28, 2007 10:20 pm
Location: Hamilton, Ontario, Canada

Will this work??

Post by Todlerone »

Hello all and TGIF (if it fits). I've just written some code I need for my baseball web site and I'm not close (ie, at home) to verify that it works. It is a loop to provide a teams "winning streak" output. I'm just curious if I'll have any problem with evaluating the $typestatus then reassign the same with a new value within the loop. I'm looking to output a type and value to it, example, W3, L2 or U3 (unbeaten in 3).

Code: Select all

 
for ($x=0;$x<$num_teams;$x++){
    $typenum=0;
    $v=sizeof($outcome[$x]);
    $typestatus=$outcome[$x][0];
    for ($y=0;$y<$v;$y++){
        $type=$outcome[$x][$y];
        if ($type=="W"){
            if ($typestatus=="W"){
                $typenum+=1;
            }elseif ($typestatus=="L"){
                $typestatus="W";
                $typenum=1;
            }elseif ($typestatus=="T"){
                $typestatus="U";
                $typenum+=1;
            }elseif ($typestatus=="U"){
                $typenum+=1;
            }
        }elseif ($type=="L"){
            if ($typestatus=="W"){
                $typestatus="L";
                $typenum=1;
            }elseif ($typestatus=="L"){
                $typenum+=1;
            }elseif ($typestatus=="T"){
                $typestatus="L";
                $typenum=1;
            }elseif ($typestatus=="U"){
                $typestatus="L";
                $typenum=1;
            }
        }elseif ($type=="T"){
            if ($typestatus=="W"){
                $typestatus="U";
                $typenum+=1;
            }elseif ($typestatus=="L"){
                $typestatus="U";
                $typenum=1;
            }elseif ($typestatus=="T"){
                $typestatus="U";
                $typenum+=1;
            }elseif ($typestatus=="U"){
                $typenum+=1;
            }
        }//end loop (if ($type=="W"))
    }//end loop (for ($y=0;$y<$v;$y++))     
}//end loop (for ($x=0;$x<$num_teams;$x++))
 
Thanks in advance. The code in theory works exatually how I need it to barring any problems with the code.
Todlerone
Forum Commoner
Posts: 96
Joined: Sun Oct 28, 2007 10:20 pm
Location: Hamilton, Ontario, Canada

Re: Will this work??

Post by Todlerone »

It works great....
Post Reply