0
How could I generate a new array in a loop? for example make the machine generate array1[], array2[]
I can create a variable like this with the following code:
${'var'.$i}
// E isso virar $var1, $var2
But what about an array like I would do? Thank you all and a strong hug!
Opa valeu partner! Actually here he is creating new arrays? Or in case 20 variables within a single array? Because what I needed was actually the loop for or while, create for me a certain number of arrays and not variables within arrays, I do not know if I could explain straight hehe anyway thank you hugs!
– Rafael Teixeira
A multidimensional array of help ?
– Maiky Jonathan
Poxa to be quite honest I’m kind of new in programming mainly in php hehe, MAYBE it helps, I don’t know, but I’ve never used... Do you think it would be the only way? Alias what you say is Matrix right?
– Rafael Teixeira
$var = array(); for ($i=0; $i <= 20 ; $i++) { array_push($var,array(["var" . $i]); } #If you need it, go to array 3 and get the first result. echo $var[3][0];
– Maiky Jonathan
Man mto thanks for the return! This for me was very new hehe... It took me a while to thank you here because I wanted to test some things with the code you made, but I’m still a little lost... For example... Inside this is, how do I select an array that was generated inside, but not a specific one but a $i even number... and add some value to it? I do not know if it is already and ask too much if it is Sorry hehe anyway I am very grateful for the help!!! I’m trying from here hugs! o/
– Rafael Teixeira
For example... add some content to it like: array_push(array(["var".$i]), "watermelon", "potato");... And access it maybe to printar or pebble print_r(array(["var".$i));... But apparently this method does not work hehe
– Rafael Teixeira