如果我有一个这样的数组...删除数组元素提供
array('1','2','3','4','10')
...我怎么能删除其值我公司供应的元素之前的元素。
例如:
如果我供给1
然后array = (1,2,3,4,10)
如果它是2
然后array = (2,3,4,10) //Remove the numbers before 2
如果它是3
然后array = (3,4,10) //Remove the numbers before 3
如果它是4
然后array = (4,10) //Remove the numbers before 4
如果是10
然后array = (10) //Remove all before the 10
我目前想用if else
做的。但有没有办法使用某种PHP数组函数本身来做到这一点。
如果枚举数组,使用[array_search()](http://www.php.net/manual/en/function.array-search.php)来查找元素键,然后使用[array_splice( )](http://www.php.net/manual/en/function.array-splice.php) –
@MarkBaker我的数组就像我的问题。 $ array = array(“1”,“2”,“3”,“4”,“10”) – Norman