4
I’m developing a loop to compare two tables in a database. The purpose is to know how many people were appointed by the same employee of the company. For this, I need to start a array as follows:
foreach($linhas as $linha){
$varivael = array( $linha['nome'] => 0);
};
The problem is that this way only adds the last item of the table, and I want them all inserted, which is as follows:
$varivael = array( $linha['nome'] => 0, $linha['nome'] => 0, $linha['nome'] => 0, ...);
I thought about using the push() array_push, but it only inserts the element and not the index.
How to proceed?
Within the
foreach
try to do$varivael[$linha['nome']] = 0
.– Woss
Apparently it worked. Although I’ve done it again, for some reason, this one right. Thank you.
– Rafael Pessoa