PHP数组排序和分组

时间:2017-01-03 15:33:18

标签: sorting

下面是一个包含count及其按钮url的数组,需要对新数组中的重复项进行排序和分组并排序:

$array = [[
			[1,'Firsts','https://test.com/button-1', ''],
			[1,'Seconds','https://test.com/button-2', ''],
			[2,'Testing-Button','https://test.com/copy.jpg', ''],
			[19,'LetsStart','https://test.com/', ''],
			[4,'Firsts','https://test.com/button-3', ''],
			[5,'Seconds','https://test.com/button-4', ''],
			[10,'Firsts','https://test.com/button-5', '']
	]];

预期输出:

$output = [[
			[1,'Firsts','https://test.com/button-1', ''],
			[1,'Seconds','https://test.com/button-2', ''],
			[2,'Testing-Button','https://test.com/copy.jpg', ''],
			[19,'LetsStart','https://test.com/', '']
		],
		[
			[4,'Firsts','https://test.com/button-3', ''],
			[5,'Seconds','https://test.com/button-4', '']
		],
		[
			[10,'Firsts','https://test.com/button-5', '']
		]
	  ];

0 个答案:

没有答案