problema de matriz aleatoria de PHP

  • jamesbond
  • Novice
  • Novice
  • No Avatar
  • Registrado: Ago 22, 2011
  • Mensajes: 19
  • Status: Offline

Nota Noviembre 19th, 2011, 10:07 pm

Tengo una lista de palabras de html importado como una matriz y y 2 para bucles de col y filas. mi problema es que necesito para obtener la función de agarrar una carta aleatoria de la matriz de la lista de palabras y poner una carta aleatoria de la lista de palabras en cada celda
Código: [ 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
  • Registrado: 25 Feb 2008
  • Mensajes: ?
  • Loc: Ozzuland
  • Status: Online

Nota Noviembre 19th, 2011, 10:07 pm

  • jamesbond
  • Novice
  • Novice
  • No Avatar
  • Registrado: Ago 22, 2011
  • Mensajes: 19
  • Status: Offline

Nota Noviembre 22nd, 2011, 1:35 pm

agradecería enormemente cualquier ayuda al respecto
  • Bogey
  • Bogey
  • Genius
  • Avatar de Usuario
  • Registrado: Jul 14, 2005
  • Mensajes: 8211
  • Loc: USA
  • Status: Offline

Nota Noviembre 26th, 2011, 10:58 pm

Ya tienes casi todo lo que...todo acerca de ponerlos en el lugar correcto:)

PHP Código: [ 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
  • Registrado: Ago 22, 2011
  • Mensajes: 19
  • Status: Offline

Nota Noviembre 27th, 2011, 12:49 pm

Lo había averiguado. Mal post código terminado cuando llegue a casa

Publicar Información

  • Total de mensajes en este tema: 4 mensajes
  • Usuarios navegando por este Foro: Kurthead+1 y 129 invitados
  • No puede abrir nuevos temas en este Foro
  • No puede responder a temas en este Foro
  • No puede editar sus mensajes en este Foro
  • No puede borrar sus mensajes en este Foro
  • No puede enviar adjuntos en este Foro
 
 

© 2011 Unmelted, LLC. Ozzu® es una marca registrada de Unmelted, LLC