I'm trying to create a tiles matching (memory) game. I'm a beginner and I'm confused how exactly to start on creating one dimensional array for sessions. The tiles should be at least 30 with text values. When the user select first tile (reveal the text) and then user select second tile; if two tiles match, should remove tiles from the board. When user complete the board, user should be presented with a summary of their performance and the option to play again (new board should be generated).
I have no clue how to make 1d dimensional array or make random_suffle().
I try to run it and it doesn't show up any errors. Its just blank page.
Here is what I have so far:
<?php
session_start();
if(!isset($_SESSION['game']))
{
$tile = array("Item 1", "Item 2");
for($n = 3; $n<11; $n++)
{
$tile[] = "Item ".$n;
}
}
else
{
$tile = $_SESSION['game'];
}
echo "<form><table>";
echo "<tr>";
$rowCount=0;
for($i=0; $i<count($_SESSION['game']); $i++)
{
// if($i%6==0)
$rowCount++;
if($rowCount==6)
{
echo "</tr>\n<tr>";
$rowCount=0;
}
if(($_SESSION['flip1']==$i)or($_GET['index']==$i))
{
echo "<td>".$_SESSION['game'][$i]."</td>";
}
else
{
echo "<td><a href=\"".$_SERVER['PHP_SELF']."?index=".$i."\">flip me!</a></td>";
}
}
echo "</tr>";
echo "</table></form>";
?>