dongpanbo4727 2011-02-28 02:11
浏览 8
已采纳

多维数组搜索

From this array how could I get that array which first element is 128 and the second is 64.

$positions = array(
    array('64','64','home.png','www.sdsd.vf'),
    array('128','64','icon-building64.png','www.sdsd.vf')
);

Thanks for your help Ungi.

  • 写回答

1条回答 默认 最新

  • douquqiang1513 2011-02-28 02:14
    关注
    foreach($positions as $position) {
    
       if ($position[0] == '128' AND $position[1] == '64') {
          // This is it!
       }
    
    }
    

    Or you could drop the other members with array_filter().

    $positions = array_filter($positions, function($position) {
    
       return ($position[0] == '128' AND $position[1] == '64');
    
    });
    
    var_dump($positions);
    

    Output

    array(1) { [1]=> array(4) { [0]=> string(3) "128" [1]=> string(2) "64" [2]=> string(19) "icon-building64.png" [3]=> string(11) "www.sdsd.vf" } } 
    

    See it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大