如图所示是一个二维数组[别纠结,为了方便我将其转为了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"}]