在阵列中取出整数比PHP点¯x少 [英] Remove integers in array less than X with PHP
本文介绍了在阵列中取出整数比PHP点¯x少的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有值的整数从0到100我想删除小于号X的整数,并保持了比号X相等或更大的那些阵列。
I have an array with integers of values from 0 to 100. I wish to remove integers that are less than number X and keep the ones that are equal or greater than number X.
我使用PHP。
谢谢!
推荐答案
一个难看一点使用笨重的 create_function
,而是直截了当:
A little ugly using the clunky create_function
, but straight forward:
$filtered = array_filter($array, create_function('$x', 'return $x >= $y;'));
有关PHP> = 5.3:
For PHP >= 5.3:
$filtered = array_filter($array, function ($x) { return $x >= $y; });
设置 $ Y
到任何你想要的。
这篇关于在阵列中取出整数比PHP点¯x少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文