How to print an arrangement with a foreach in CODEIGNITER?

0

In the DB model , the query is fine, in the Controller the information is sent correctly to the view but in the View not I know how to print the matrix in a foreach. The only way to print the arrangement is with the following:

<?php 
     print_r($mostrar2);
?>

and I get the following information:

  

Array ([0] => Array ([name] = > Cinema [command_name] = >   systemctl disable madness [value] = > 12) [1] = > Array ([name] = >   Cinema [command_name] = > systemctl disable madness [value] = > enable   ) [2] = > Array ([name] = > Cinema [command_name] = & systemctl   disable madness [value] = > sas) [3] = > Array ([name] = > Cinema   [command_name] = > systemctl disable madness [value] = > enable) [4]   = > Array ([name] = > Cinema [command_name] = > systemctl disable insanity [value] = > sas) [5] = > Array ([name] = > Cinema   [command_name] = > systemctl disable madness [value] = > false) [6] = >   Array ([name] = > Cinema [command_name] = > systemctl disable   madness [value] = > false) [7] = > Array ([name] => Pharmacies AS   [command_name] = > systemctl disable madness [value] = > false) [8] = >   Array ([name] = > Pharmacies AS [command_name] => systemctl disable   madness [value] = > sas) [9] = > Array ([name] => Pharmacies AS   [command_name] = > systemctl disable BBB [value] = > ) [10] = > Array (   [name] = > Pharmacies AS [command_name] = > systemctl disable vsftpd   [value] = > sad) [11] = > Array ([name] = > iQOS [command_name] = >   systemctl test writing solution [value] = > false) [12] = > Array (   [name] = > local [command_name] = > systemctl disable BBB [value] = >   sas) [13] = > Array ([name] = > local [command_name] = & systemctl   disable madness [value] = > false) [14] = > Array ([name] = > local   [command_name] = > systemctl disable madness [value] = > )

I need you to only show me these values

Cinema, systemctl disable madness, 12

    
asked by Neri Dex 12.12.2018 в 17:35
source

1 answer

0

I have translated your array of objects into php, since you ask that it be done in php, there is a lack of data to which you show but I hope I can help you.

$datos = [
    ['nombre'=> 'Cinema', 'nombre_comando'=> 'systemctl disable locura', 'valor'=> '12'],
    ['nombre'=> 'Cinema', 'nombre_comando'=> 'systemctl disable locura', 'valor'=> 'enable'],
    ['nombre'=> 'Cinema', 'nombre_comando'=> 'systemctl disable locura', 'valor'=> 'sas'],
    ['nombre'=> 'Cinema', 'nombre_comando'=> 'systemctl disable locura', 'valor'=> 'enable'],
    ['nombre'=> 'Cinema', 'nombre_comando'=> 'systemctl disable locura', 'valor'=> 'false'],
    ['nombre'=> 'Cinema', 'nombre_comando'=> 'systemctl disable locura', 'valor'=> 'sad']];

We go through the corresponding arrangement.

foreach($datos as $key){
   echo $key['nombre'].', '.$key['nombre_comando'].', '.$key['valor'].'<br>';
}
    
answered by 12.12.2018 / 18:04
source