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>";
?>

Its going to be hell like complicate than the script above.The script above is producing the blank page because there is nothing to show up in the page ,inside the table it produces.
I will advice you to go step by step as below -
step 1 - Lets just create the simple html page to show the plain 5 by 5 matrix of tiles, you can have some css as you want(play with the css to create the tiles effect and the scribbled letters on it, later)
step 2 - introduce some javascript to do something on click of the tiles
step 3 - Lets do this much first to get the clear picture of the scenario ahead..!!This step will involve some php to produce the points for the user and your session thing is there, apart amongst other things.

So here is the html for our first step -

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css"  >
.tableclass{
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
font-weight:bold;
font-style:inherit;
}
.td-class{
color:#FFFFFF;
background-color:#666666;
}
</style>
</head>

<body>
<table class="tableclass" width="200">
  <tr>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
  </tr>
  <tr>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
  </tr>
  <tr>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
  </tr>
  <tr>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
  </tr>
  <tr>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
  </tr>
</table>

</body>
</html>

Hi, I want Memory tile game in php.
Please someone help me and give me coding for memory tile game.
Thanks

just a hint based on your code. foreach loop works better than for loop!
$array = array("Moja", "Mbili", "Tatu");

foreach(array as $key=>$value){
    echo "Array Key is: ".$key." And value is: ".$value;
}

Arghhhhh!
You have just resurrected old thred ;)
Let them die and open new thread for your question!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.