How to filter an array by a condition

后端 未结 7 682
长发绾君心
长发绾君心 2020-11-22 06:12

I have an array like this:

array(\"a\" => 2, \"b\" => 4, \"c\" => 2, \"d\" => 5, \"e\" => 6, \"f\" => 2)

Now I want to fi

相关标签:
7条回答
  • 2020-11-22 07:09
      foreach ($aray as $key => $value) {
        if (2 != $value) {
          unset($array($key));
        }
      }
    
      echo 'Items in array:' . count($array);
    
    0 讨论(0)
提交回复
热议问题