I would like to access the direct key of an array object without having to loop (foreach)
Instead of being like this:
$nome = "";
$codigo = 0;
$objeto = DB::select( "SELECT NOME FROM TABELA WHERE CODIGO = ?", array( $codigo ) );
foreach ( $objeto as $obj ){
$nome = $obj->nome;
}
echo $nome;
I wish I did not need foreach
Type
$nome = $objeto->nome;
But it gives the following message:
Trying to get property of non-object