dslfq06464 2013-04-24 05:20 采纳率: 0%
浏览 27

PHP特定值的多维数组

I have an array in multidimensional, which i want to get the array set only match my specific value, right now i have a column call related_users, I need a statement that will get this array values only when is this array's related_user value is 1.

Array
(
[0] => Array
    (
        [id] => 1
        [advertiser] => Hairvolution
        [postdate] => 
        [campaign_period] => 
        [related_users] => 1
        [reporting_period] => 
        [Delivered Impressions] => 1439763
        [Clicks] => 4124
        [Click-Through Rate] => 0.29
    )

[1] => Array
    (
        [id] => 4
        [advertiser] => 
        [postdate] => 
        [campaign_period] => 
        [related_users] => 2
        [reporting_period] => 
        [Delivered Impressions] => 
        [Clicks] => 
        [Click-Through Rate] => 
    )

[2] => Array
    (
        [id] => 7
        [advertiser] => maxlibin
        [postdate] => 
        [campaign_period] => 
        [related_users] => 2
        [reporting_period] => 
        [Delivered Impressions] => 
        [Clicks] => 
        [Click-Through Rate] => 
    )
 [3] => Array
    (
        [id] => 8
        [advertiser] => maxlibin
        [postdate] => 
        [campaign_period] => 
        [related_users] => 1
        [reporting_period] => 
        [Delivered Impressions] => 
        [Clicks] => 
        [Click-Through Rate] => 
    )

[4] => Array
    (
        [id] => 9
        [advertiser] => maxlibin
        [postdate] => 
        [campaign_period] => 
        [related_users] => 1
        [reporting_period] => 
        [Delivered Impressions] => 
        [Clicks] => 
        [Click-Through Rate] => 
    )
}
  • 写回答

6条回答 默认 最新

  • duancenxiao0482 2013-04-24 05:23
    关注

    Use for loop and iterate it and check the related_users value ,if it matches 1 then append the array to new array.

    $arr = array();
    for($i=0;$i< count($your_array);$i++) {
        if($your_array[$i]['related_users'] == 1) {
            $arr[] = $your_array[$i];
        }
    }
    print_r($arr);
    
    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效