php替换二维数组键名,php怎么将二维数组键名相同的元素转为新的数组?不用for,foreach循环...

如图所示是一个二维数组[别纠结,为了方便我将其转为了json], 其中type只有两个值1和2,

现在需要将type=1的元素转到$new数组中,type=2的转到$old数组中。

除了用循环还有什么方法没?

附上json:

[{"id":"10","type":"1","cpu":"Intel Xeon E3-1241v3","cores":"4","ram":"16","hard_drive":"1TB SATA","port_speed":"100Mbps","transfer":"20TB","ipmi_kvm":"Y","price":"148","price1":"142","price2":"135","price3":"127","price4":"118","add_time":"0000-00-00 00:00:00","edit_time":"0000-00-00 00:00:00","ip":null},{"id":"11","type":"1","cpu":"Intel Xeon E5-1650v2","cores":"6","ram":"16","hard_drive":"1TB SATA","port_speed":"100Mbps","transfer":"20TB","ipmi_kvm":"Y","price":"198","price1":"190","price2":"180","price3":"170","price4":"158","add_time":"0000-00-00 00:00:00","edit_time":"0000-00-00 00:00:00","ip":null},{"id":"12","type":"1","cpu":"Dual Intel Xeon E5-2630v2","cores":"12","ram":"64","hard_drive":"1TB SATA","port_speed":"100Mbps","transfer":"20TB","ipmi_kvm":"Y","price":"348","price1":"334","price2":"317","price3":"299","price4":"278","add_time":"0000-00-00 00:00:00","edit_time":"0000-00-00 00:00:00","ip":null},{"id":"4","type":"2","cpu":"Intel Core i3-2100T","cores":"2","ram":"16","hard_drive":"1TB SATA","port_speed":"100Mbps","transfer":"20TB","ipmi_kvm":"Y","price":"68","price1":"65","price2":"61","price3":"56","price4":"51","add_time":"2015-09-16 16:36:39","edit_time":"2015-09-16 16:36:42","ip":"127.0.0.1"},{"id":"5","type":"2","cpu":"Intel Xeon X3470","cores":"4","ram":"16","hard_drive":"1TB SATA","port_speed":"100Mbps","transfer":"20TB","ipmi_kvm":"Y","price":"78","price1":"75","price2":"70","price3":"65","price4":"59","add_time":"2015-09-16 16:37:24","edit_time":"2015-09-16 16:37:27","ip":"127.0.0.1"},{"id":"6","type":"2","cpu":"Intel Core i5-2400","cores":"4","ram":"16","hard_drive":"1TB SATA","port_speed":"100Mbps","transfer":"20TB","ipmi_kvm":"Y","price":"88","price1":"84","price2":"79","price3":"73","price4":"66","add_time":"2015-09-16 16:38:14","edit_time":"2015-09-16 16:38:16","ip":"127.0.0.1"},{"id":"7","type":"2","cpu":"Intel Core i7-2600","cores":"4","ram":"16","hard_drive":"1TB SATA","port_speed":"100Mbps","transfer":"20TB","ipmi_kvm":"Y","price":"98","price1":"94","price2":"88","price3":"81","price4":"74","add_time":"2015-09-16 16:40:02","edit_time":"2015-09-16 16:40:04","ip":"127.0.0.1"},{"id":"8","type":"2","cpu":"Intel Core i7-3770S","cores":"4","ram":"16","hard_drive":"1TB SATA","port_speed":"100Mbps","transfer":"20TB","ipmi_kvm":"Y","price":"118","price1":"113","price2":"106","price3":"98","price4":"89","add_time":"2015-09-16 16:40:50","edit_time":"2015-09-16 16:40:52","ip":"127.0.0.1"},{"id":"9","type":"2","cpu":"Dual Intel Xeon X5650","cores":"12","ram":"64","hard_drive":"1TB SATA","port_speed":"100Mbps","transfer":"20TB","ipmi_kvm":"Y","price":"318","price1":"305","price2":"286","price3":"264","price4":"239","add_time":"2015-09-16 16:42:00","edit_time":"2015-09-16 16:42:02","ip":"127.0.0.1"}]

bVpVJD

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值