简体   繁体   English

未设置数组中的键范围

[英]unset range of keys in an array

How can i unset a range of keys between say 70 to 80 in an array like this? 如何在这样的数组中取消70到80之间的一系列键?

[63] => Computer Science and Informatics
[64] => Dentistry
[65] => Development Studies
[66] => Drama, Dance and Performing Arts
[67] => Earth Systems and Environmental Sciences
[68] => Economics and Econometrics
[69] => Education
[70] => Electrical and Electronic Engineering
[71] => English Language and Literature
[72] => Epidemiology and Public Health
[73] => European Studies
[74] => French
[75] => General Engineering and Mineral & Mining Engineering
[76] => Geography and Environmental Studies
[77] => Geography and Environmental Studies
[78] => German, Dutch and Scandinavian Languages
[79] => Health Services Research
[80] => History
[81] => History of Art, Architecture and Design
[82] => Iberian and Latin American Languages
[83] => Infection and Immunology
[84] => Italian
[85] => Law
[86] => Library and Information Management
[87] => Linguistics
[88] => Mechanical, Aeronautical and Manufacturing Engineering
[89] => Metallurgy and Materials
[90] => Middle Eastern and African Studies

You can try array_slice 你可以尝试array_slice

$return = array_slice($original, 0, 60)

then 然后

$return = $return+array_slice($original, 70)

or 要么

array_splice array_splice

$return = array_splice($original, 60, 10)

There isn't really a shortcut to this: 这没有真正的捷径:

for ($i = 70; $i <= 80; $i++)  
    unset($array[$i]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM