2
I created an array in which each index stores another array - both global so that the values are not deleted. The problem is in displaying each element, when I try, PHP returns me "Notice: Array to string Conversion"
Code:
function cadastrar($nome, $raca, $cor, $tipoPelo){
$_SESSION['array1'][] = array($nome, $raca, $cor, $tipoPelo);
$_SESSION['array2'][] = $_SESSION['array1'];
}
function listar(){
for($i = 0; $i < sizeof($_SESSION['array2']); $i++){
echo $_SESSION['array2'][$i];
}
}
With var_dump($_SESSION['array2']); displays:
Arrayarray(3) { [0]=> array(1) { [0]=> array(4) { [0]=> string(0) "" [1]=> string(0) "" [2]=> string(0) "" [3]=> string(0) "" } } [1]=> array(2) { [0]=> array(4) { [0]=> string(0) "" [1]=> string(0) "" [2]=> string(0) "" [3]=> string(0) "" } [1]=> array(4) { [0]=> string(5) "nome1" [1]=> string(5) "raca1" [2]=> string(4) "cor1" [3]=> string(5) "tipo1" } } [2]=> array(3) { [0]=> array(4) { [0]=> string(0) "" [1]=> string(0) "" [2]=> string(0) "" [3]=> string(0) "" } [1]=> array(4) { [0]=> string(5) "nome1" [1]=> string(5) "raca1" [2]=> string(4) "cor1" [3]=> string(5) "tipo1" } [2]=> array(4) { [0]=> string(5) "nome2" [1]=> string(6) "raça2" [2]=> string(4) "cor2" [3]=> string(5) "tipo2" } } }
does so, in the list of a
var_dump($_SESSION['array2'])
and edit the question with the result.– Lodi