Possible duplicate:remove key range in array
I have an array of $ test, it contains 1000 elements with a random key between 1 and 10000, I want to disable array elements of a certain range of keys. for example, I want to disable elements if the key value is from 500 to 600. Now I use the foreach loop for this. Any other php shortcut for this?
Original link
remove key range in array
You can try array_slice
$return = array_slice($original, 0, 60)
then
$return = $return+array_slice($original, 70)
or
array_splice
$return = array_splice($original, 60, 10)
How about this (untested, hand written)
function unsetRange($arr,$from,$to) { for($i=$from;$i<=$to;$i++) unset($arr[$i]); } // Unset elements from 500 to 600 unsetRange($myArr,500,100);
Source: https://habr.com/ru/post/925815/More articles:Diff tool that can be integrated into a C # application - c #Trying to configure CCLabelTTF with an integer as part of its string in Cocos2d-X C ++ - c ++@ font-face rendering problem in paragraph tag, Chrome Android 4 - androidJQuery Mobile 1.2RC-1 non-downloadable post - jqueryC # code execution using NRefactory 5 - c #unset range of keys in an array - arraysiCloud synchronization with application using sqlite database - IOS - ioszend framework 2 add a new controller - zend-framework2How can I filter unit test in visual studio 2012 by category? - visual-studio-2012Facebook Create a new application error - "should not contain protocol information." - facebookAll Articles