Good day, wizard!
I am a beginner programming webmaster, and I would like to know and get a little idea about array(); and foreach(); .
There is the following code:
$array = array(); foreach ($file[1] as $key => $value) { $array['file'][] = [ 'bla-bla-bla' => $file[1][$key], 'bla-bla-bla2' => $file[2][$key], ]; } So, could this code be explained in plain language?
Also the question: if you remove $array = array(); , it still works. Why? Or is it optional in my case? What is he doing at all? Creates an empty array or what?
PS: In the office. The websites have a lot of information, but unfortunately, I don’t understand anything there.
$array = array();- this is just the initialization of an empty array. It's like writing$string = '';if you remove this line, it will work, because in php it is not necessary to initiate variables before they begin filling, and if you remove this line, then$arrayinitiated already insideforeach()- Al Mr