php 取得元素的索引,如何从PHP数组中取消设置数值索引元素?

我有一个数组集合,它包含数字索引和非数字索引。我想取消设置所有的数字索引。

我的数组是这样的。

Array

(

[554] => Array

(

[0] => 554

[1] => Jiaqi Zheng

[2] => Female

[3] => 28

[4] => Table Tennis

[5] =>

[6] =>

[7] =>

[8] =>

[rank] => 554

[athlet_name] => Jiaqi Zheng

[gender] => Female

[sport] => Table Tennis

)

[555] => Array

(

[0] => 555

[1] => Zach Ziemek

[2] => Male

[3] => 23

[4] => Athletics

[5] =>

[6] =>

[7] =>

[8] =>

[rank] => 555

[athlet_name] => Zach Ziemek

[gender] => Male

[sport] => Athletics

)

)

这里我必须取消设置所有的数字索引。

我用这种不安的东西,它对我来说工作得很好。

unset(

$history_years_wise_country_wise_details_arr[ $history_years_wise_country_wise_details_info[0]][0],

$history_years_wise_country_wise_details_arr[$history_years_wise_country_wise_details_info[0]][1],

$history_years_wise_country_wise_details_arr[$history_years_wise_country_wise_details_info[0]][2],

$history_years_wise_country_wise_details_arr[$history_years_wise_country_wise_details_info[0]][3],

$history_years_wise_country_wise_details_arr[$history_years_wise_country_wise_details_info[0]][4],

$history_years_wise_country_wise_details_arr[$history_years_wise_country_wise_details_info[0]][5],

$history_years_wise_country_wise_details_arr[$history_years_wise_country_wise_details_info[0]][6],

$history_years_wise_country_wise_details_arr[$history_years_wise_country_wise_details_info[0]][7],

$history_years_wise_country_wise_details_arr[$history_years_wise_country_wise_details_info[0]][8]

);

我有没有办法减少代码行?这里0到8是一个系列。

我可以在一行代码中取消设置所有索引,因为所有索引都是数字的吗?

是否可以改用正则表达式?

我想要类似的东西

unset(

$history_years_wise_country_wise_details_arr[ $history_years_wise_country_wise_details_info[0]][anything_which_will_take_index_from_0_to_8]);

有什么建议吗?

谢谢你

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值