Answer the question
In order to leave comments, you need to log in
How to run an Active Record object through a loop?
$alana_first = Alaniatape::find()->where(['category' => "ALANÆ LIFE",'conclusion_top' => '1'])->orderBy('id DESC')->all();
<?php foreach($alana_first as $key => $value){
echo $key;
}?>
Answer the question
In order to leave comments, you need to log in
Firstly, it's not a fact that you received an array and not null, maybe there are no records corresponding to the request.
Secondly, you got an array of objects, if you need a pure array, then you should use asArray()
And finally - just look at what's in the array:
<pre>
<?php print_r($alana_first); ?>
</pre>
Trying to display $key in foreach what do you want to see? Record primary key? To do this, you need to do $value->primaryKey
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question