Answer the question
In order to leave comments, you need to log in
Why doesn't array_filter work?
here is the code instead of a thousand code var_dump($model-image);
I get
object(common\models\Image)#2028 (9) {
["class"]=> NULL
["_attributes":"yii\db\BaseActiveRecord":private]=> array(13) {
["title_alt"]=> string(46) "Ложное обвинение (сериал)"
["path"]=> string(15) "serial/2016/10/"
["name"]=> string(10) "979247.jpg"
["for_home"]=> int(1) }
}
$img = array_filter($model->image, function($item) {
return $item->for_home == 1;
});
var_dump($img)
Answer the question
In order to leave comments, you need to log in
For some reason, it seems that you are passing an object to array_filter and not an ARRAY of objects
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question