First PHP associative array key does not work

2

In PHP, the problem I have is that when I go through an associative array like this, it shows me all the fields correctly,

foreach ($documentos as $doc) { 
    foreach ($doc as $key => $value) {
        echo $key .' --> '. $value . '<br/>';
    }
}

but when you perform the search directly with the key, the value of the first key is not displayed.

foreach ($documentos as $doc){
    echo $doc['nid'];     //Primera clave de mi array asociativo. No se muestra 
    echo $doc['titulo'];  //Segunda clave de mi array asociativo. Si se muestra.
}

Could someone explain to me what is happening and how can I solve it?

    
asked by Javier Rodríguez 05.03.2018 в 10:04
source

0 answers