php problem with function
- by moustafa
i have this
function drawBoard(){
global $cBoard;
$R = "<img src=rp.gif>"; //Red piece
$B = "<img src=bp.gif>"; //black piece
$ES = "<img src=blank.gif>"; // legal square image
$IS = "<img src=blank1.gif>"; //illegal square image
$cBoard = array(
array($IS, $R, $IS, $R, $IS, $R, $IS, $R),
array($R, $IS, $R, $IS, $R, $IS, $R, $IS),
array($IS, $R, $IS, $R, $IS, $R, $IS, $R),
array($ES, $IS, $ES, $IS, $ES, $IS, $ES, $IS),
array($IS, $ES, $IS, $ES, $IS, $ES, $IS, $ES),
array($B, $IS, $B, $IS, $B, $IS, $B, $IS),
array($IS, $B, $IS, $B, $IS, $B, $IS, $B),
array($B, $IS, $B, $IS, $B, $IS, $B, $IS)
);
echo "<table border='3' width='200'>n";
foreach ($cBoard as $row){
switch($row){
case "8": $row = 0; break;
case "7": $row = 1; break;
case "6": $row = 2; break;
case "5": $row = 3; break;
case "4": $row = 4; break;
case "3": $row = 5; break;
case "2": $row = 6; break;
case "1": $row = 7; break;
}
echo "<tr>n";
foreach ($row as $piece){
echo "<td>";
echo "$piece ";
echo "</td>n";
switch($Piece){
case "A": $piece = 0; break;
case "B": $piece = 1; break;
case "C": $piece = 2; break;
case "D": $piece = 3; break;
case "E": $piece = 4; break;
case "F": $piece = 5; break;
case "G": $piece = 6; break;
case "H": $piece = 7; break;
}
}
}
echo "</tr>n";
echo "</table>n";
}
now im trying to parse a file into the array with color codes
how i can do that