return array(array) of a php function

Asked

Viewed 837 times

1

I am storing the data of a database in an array in a file called php functions.:

    while($line = mysqli_fetch_array($execute)){
        $tabela[$a][$b] = $line['Activit'];
        $tabela[$a][$b+1] = $line['Usuario'];
        $tabela[$a][$b+2] = $line['Data_monit'];
        $a++;
    }
    return array($tabela);

and insert the returned array into another array in another file filter.php:

 $tabela = corrige_filter($data, $modulo, $usuario, $conexao);
 while($a < 10){
 echo '<tr>';
 echo '<td>'.$tabela[$a][$b].'</td>';
 echo '<td>'.$tabela[$a][$b+1].'</td>';
 echo '<td>'.$tabela[$a][$b+2].'</td>';
 echo '</tr>';
 $a++;
 }

As expected when I print the table, it returns nothing, so my question is, how to pass the array from the first function to another array with the same matrix format.

1 answer

1


Simply use:

return $tabela;

In doing return array($tabela) you are wrapping the whole table (which was already an array) in a new array.

  • Oh yes, that was it msm, I thought q smp needed to use the array again Thanks :D

Browser other questions tagged

You are not signed in. Login or sign up in order to post.