在数组未设置范围键 [英] unset range of keys in an array

查看:173
本文介绍了在数组未设置范围键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能取消设置范围说,在这样的一个数组?

70到80之间的键

  [63] =>计算机科学和信息
[64] =>牙科
[65] =>发展研究
[66] =>戏剧,舞蹈和表演艺术
[67] =>地球系统与环境科学
[68] =>经济学和计量经济学
[69] =>教育
[70] =>电气与电子工程
[71] =>英语语言文学
[72] =>流行病学和公共卫生
[73] =>欧洲研究
[74] =>法国
[75] =>一般工程及矿产和放大器;矿业工程
[76] =>地理与环境研究
[77] =>地理与环境研究
[78] =>德国,荷兰和斯堪的纳维亚语言
[79] =>卫生服务研究
[80] =>历史
[81] =>艺术,建筑和设计史
[82] =>伊比利亚和拉丁美洲的语言
[83] =>感染与免疫
[84] =>意大利
[85] =>法
[86] =>图书馆和信息管理
[87] =>语言学
[88] =>机械,航空和制造工程
[89] =>冶金与材料
[90] =>中东和非洲研究


解决方案

有没有真正的捷径是:

 为($ I = 70; $ I< = 80; $ I ++)
    未设置($数组[$ i]);

How can i unset a range of keys between say 70 to 80 in an array like this?

[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

解决方案

There isn't really a shortcut to this:

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

这篇关于在数组未设置范围键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆