常见数组使用场景

1.判断二维数组 是否存在某个值  array_column  in_array

//身份标签
    $identity = [];
    $is_good_comment = db('Comment')
      ->field('ID')
      ->where('ObjectID', $person['id'])
      ->where('ParentID', 0)
      ->where('Type', 1) // 外部评价
      ->where('Score', 5)
      ->where('Status', 1)
      ->find();

    $person_photo = db('File')
        ->field('ID,Description,SubType')
        ->where('OwnerID', $person['MyUserID'])
        ->where('Type', 'personphoto')
        ->where('(SubType IN (2,3,4,5))')
        ->where('Status', 0)
        ->order('SubType')
        ->select();
    
    //--------------------------------
    $subtype_list= array_column($person_photo,'SubType');
    
    if($is_good_comment || in_array(2, $subtype_list) || in_array(3, $subtype_list

版权声明:本文为qq_39856096原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。