problème de tableau aléatoire de PHP

  • jamesbond
  • Novice
  • Novice
  • No Avatar
  • Inscription: Aoû 22, 2011
  • Messages: 19
  • Status: Offline

Message Novembre 19th, 2011, 10:07 pm

J'ai une liste de mots html importé comme un tableau et et 2 pour les boucles de col et de lignes. mon problème est qu'il faut obtenir la fonction de saisir une lettre aléatoire du tableau liste de mots et de placer une lettre au hasard de la liste de mots dans chaque cellule
Code: [ Select ]
function addFoils(){
global $board, $boardData;
for($row = 0; $row < $boardData["height"]; $row++){// for my rows
 for ($col = 0; $col < $boardData["width"]; $col++){//for my cols
  if($board[$row][$col] == "."){//.means to add letter to the cell
   $newLet = $_REQUEST["wordList"];//array from html wordlist
    $newLet = strtoupper($newLet);//convert to upper case
     $firstLetter = substr($newLet,0,1);//picks out first letter
      $board[$row][$col] = str_shuffle($firstLetter);//shuffles wordlist
            }
        }
    }
}
  1. function addFoils(){
  2. global $board, $boardData;
  3. for($row = 0; $row < $boardData["height"]; $row++){// for my rows
  4.  for ($col = 0; $col < $boardData["width"]; $col++){//for my cols
  5.   if($board[$row][$col] == "."){//.means to add letter to the cell
  6.    $newLet = $_REQUEST["wordList"];//array from html wordlist
  7.     $newLet = strtoupper($newLet);//convert to upper case
  8.      $firstLetter = substr($newLet,0,1);//picks out first letter
  9.       $board[$row][$col] = str_shuffle($firstLetter);//shuffles wordlist
  10.             }
  11.         }
  12.     }
  13. }
  • Anonymous
  • Bot
  • No Avatar
  • Inscription: 25 Feb 2008
  • Messages: ?
  • Loc: Ozzuland
  • Status: Online

Message Novembre 19th, 2011, 10:07 pm

  • jamesbond
  • Novice
  • Novice
  • No Avatar
  • Inscription: Aoû 22, 2011
  • Messages: 19
  • Status: Offline

Message Novembre 22nd, 2011, 1:35 pm

toute aide sur ce serait grandement appréciée
  • Bogey
  • Bogey
  • Genius
  • Avatar de l’utilisateur
  • Inscription: Juil 14, 2005
  • Messages: 8211
  • Loc: USA
  • Status: Offline

Message Novembre 26th, 2011, 10:58 pm

Vous avez déjà peu près de tout il...son tout propos de placer au bon endroit:)

PHP Code: [ Select ]
<?php
 
function addFoils()
{
    global $board, $boardData;
   
    // For my rows
    for($row = 0; $row < $boardData["height"]; $row++)
    {
        // For my cols
        for($col = 0; $col < $boardData["width"]; $col++)
        {
            // The "." means to add letter to the cell
            if($board[$row][$col] == ".")
            {
                // Array from html wordlist
                $newLet = $_REQUEST["wordList"];
               
                // Convert to upper case
                $newLet = strtoupper($newLet);
               
                // Shuffles wordlist
                $board[$row][$col] = str_shuffle($newLet);
               
                // Picking the first letter as the random one
                $randLetter = substr($newLet, 0, 1);
            }
        }
    }
}
?>
  1. <?php
  2.  
  3. function addFoils()
  4. {
  5.     global $board, $boardData;
  6.    
  7.     // For my rows
  8.     for($row = 0; $row < $boardData["height"]; $row++)
  9.     {
  10.         // For my cols
  11.         for($col = 0; $col < $boardData["width"]; $col++)
  12.         {
  13.             // The "." means to add letter to the cell
  14.             if($board[$row][$col] == ".")
  15.             {
  16.                 // Array from html wordlist
  17.                 $newLet = $_REQUEST["wordList"];
  18.                
  19.                 // Convert to upper case
  20.                 $newLet = strtoupper($newLet);
  21.                
  22.                 // Shuffles wordlist
  23.                 $board[$row][$col] = str_shuffle($newLet);
  24.                
  25.                 // Picking the first letter as the random one
  26.                 $randLetter = substr($newLet, 0, 1);
  27.             }
  28.         }
  29.     }
  30. }
  31. ?>
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • jamesbond
  • Novice
  • Novice
  • No Avatar
  • Inscription: Aoû 22, 2011
  • Messages: 19
  • Status: Offline

Message Novembre 27th, 2011, 12:49 pm

I figured it out. Ill post code fini quand j'aurai Accueil

Afficher de l'information

  • Total des messages de ce sujet: 4 messages
  • Utilisateurs parcourant ce forum: Zealous et 203 invités
  • Vous ne pouvez pas poster de nouveaux sujets
  • Vous ne pouvez pas répondre aux sujets
  • Vous ne pouvez pas éditer vos messages
  • Vous ne pouvez pas supprimer vos messages
  • Vous ne pouvez pas joindre des fichiers
 
 

© 2011 Unmelted, LLC. Ozzu® est une marque déposée de Unmelted, LLC