Good afternoon,
I'm setting up a naval battle and I have the following difficulty: I am not able to access a certain array created inside a function. Within the same function I call another function that accesses this array, but PHP informs that this array is not defined. Below the framework I'm doing.
//SORTEIA OS NAVIOS
function reiniciar(){
$navios = array();
//ZERA A MATRIZ
for ($l=-1; $l < 31; $l++) {
for ($c=-1; $c < 31 ; $c++) {
$navios[$l][$c] = -1;
}
}
//CHAMA AS FUNÇÕES
sorteia(3,5,"P");//CONSTROI OS PORTA AVIÕES
}
function sorteia($quantidade,$n_posicoes,$embarcacao){
if($navios[$rand_linha][$rand_coluna] == -1){
//AQUI DIZ QUE $navios ESTA INDEFINIDO
}
}