我有一个多朦胧。具有重复值的数组。我需要它在下拉列表中只显示每个值的一个值,而后者又用于搜索查询。索引在这里并不重要。 我尝试使用array_map,serialize,array_unique等,但无法正确使用它。有些价值总是出现两次。
我在php版本4.3.2上,所以不能使用该版本之后的功能。
数组如下所示:
阵 (
[1] => Array
(
[1] => 0,9
[2] => 1,3
[3] => 1,6
[4] => 1,5
[5] => 0,0
[6] => 1,2
)
[2] => Array
(
[3] => 1,0
[4] => 2,0
[5] => 1,78
[6] => 1,44
[7] => 1,87
[8] => 1,56
[9] => 2,4
[10] => 2,93
[11] => 2,50
[12] => 1,4
[13] => 6,0
[14] => 4,0
[15] => 1,80
[16] => 3,00
)
[3] => Array
(
[5] => 1,0
[6] => 1,2
[7] => 1,5
[8] => 1,6
)
[4] => Array
(
[7] => 1,0
)
[5] => Array
(
[1] => 1,0
[2] => 1,5
[3] => 2,0
[4] => 2,5
[5] => 3,0
[6] => 3,5
[7] => 4,0
[8] => 4,5
)
[6] => Array
(
[1] => 1,5
[2] => 2,0
[3] => 2,5
[4] => 3,0
[5] => 3,5
[6] => 4,0
[7] => 4,5
[8] => 5,0
[9] => 5,5
[10] => 6,0
[11] => 6,5
[12] => 7,0
[13] => 7,5
[14] => 8,0
[15] => 8,5
[16] => 9,0
[17] => 9,5
[18] => 10,0
)
[7] => Array
(
[15] => 0,65
[16] => 0,75
[17] => 0,85
[18] => 0,90
[19] => 1,00
[20] => 1,10
[21] => 1,15
[22] => 1,25
[23] => 1,50
[24] => 1,55
[25] => 1,60
[26] => 1,80
[27] => 1,85
[28] => 2,00
[29] => 2,10
)
[8] => Array
(
[30] => 0,90
[31] => 1,00
)
[10] => Array
(
[34] => 0,65
[35] => 0,75
[36] => 0,85
[37] => 0,90
[38] => 1,00
[39] => 1,10
[40] => 1,15
[41] => 1,25
[42] => 1,50
[43] => 1,55
[44] => 1,60
[45] => 1,80
[46] => 1,85
[47] => 2,00
[48] => 2,10
)
[11] => Array
(
[34] => 1,0
[35] => 1,5
[36] => 2,0
[37] => 2,5
[38] => 3,0
[39] => 3,5
[40] => 4,0
[41] => 4,5
)
[12] => Array
(
[43] => 1,00
)
[13] => Array
(
[45] => 2,00
[46] => 2,20
[47] => 2,50
[48] => 2,75
[49] => 3,00
[50] => 3,25
[51] => 3,50
[52] => 2,60
[53] => 2,85
[54] => 1,50
[55] => 2,10
[56] => 2,35
[57] => 2,80
[58] => 2,40
[59] => 2,70
[60] => 2,25
[61] => 3,40
[62] => 2,55
[63] => 2,30
[64] => 2,65
)
)
任何帮助都将不胜感激。
答案 0 :(得分:0)
与其他子阵列相比,使每个子阵列都是唯一的(顺序很重要):
$array = array_map('unserialize', array_unique(array_map('serialize', $array)));
仅使每个子数组中的值唯一:
$array = array_map('array_unique', $array);
答案 1 :(得分:0)
$array = array_map('unserialize', array_unique(array_map('serialize', $array)));
正是我所尝试的,并且来自同一个线程,但它出现了这样:
Array(
[1] => Array
(
[1] => 0,9
[2] => 1,3
[3] => 1,6
[4] => 1,5
[5] => 0,0
[6] => 1,2
)
[2] => Array
(
[3] => 1,0
[4] => 2,0
[5] => 1,78
[6] => 1,44
[7] => 1,87
[8] => 1,56
[9] => 2,4
[10] => 2,93
[11] => 2,50
[12] => 1,4
[13] => 6,0
[14] => 4,0
[15] => 1,80
[16] => 3,00
)
[3] => Array
(
[5] => 1,0
[6] => 1,2
[7] => 1,5
[8] => 1,6
)
[4] => Array
(
[7] => 1,0
)
[5] => Array
(
[1] => 1,0
[2] => 1,5
[3] => 2,0
[4] => 2,5
[5] => 3,0
[6] => 3,5
[7] => 4,0
[8] => 4,5
)
[6] => Array
(
[1] => 1,5
[2] => 2,0
[3] => 2,5
[4] => 3,0
[5] => 3,5
[6] => 4,0
[7] => 4,5
[8] => 5,0
[9] => 5,5
[10] => 6,0
[11] => 6,5
[12] => 7,0
[13] => 7,5
[14] => 8,0
[15] => 8,5
[16] => 9,0
[17] => 9,5
[18] => 10,0
)
[7] => Array
(
[15] => 0,65
[16] => 0,75
[17] => 0,85
[18] => 0,90
[19] => 1,00
[20] => 1,10
[21] => 1,15
[22] => 1,25
[23] => 1,50
[24] => 1,55
[25] => 1,60
[26] => 1,80
[27] => 1,85
[28] => 2,00
[29] => 2,10
)
[8] => Array
(
[30] => 0,90
[31] => 1,00
)
[10] => Array
(
[34] => 0,65
[35] => 0,75
[36] => 0,85
[37] => 0,90
[38] => 1,00
[39] => 1,10
[40] => 1,15
[41] => 1,25
[42] => 1,50
[43] => 1,55
[44] => 1,60
[45] => 1,80
[46] => 1,85
[47] => 2,00
[48] => 2,10
)
[11] => Array
(
[34] => 1,0
[35] => 1,5
[36] => 2,0
[37] => 2,5
[38] => 3,0
[39] => 3,5
[40] => 4,0
[41] => 4,5
)
[12] => Array
(
[43] => 1,00
)
[13] => Array
(
[45] => 2,00
[46] => 2,20
[47] => 2,50
[48] => 2,75
[49] => 3,00
[50] => 3,25
[51] => 3,50
[52] => 2,60
[53] => 2,85
[54] => 1,50
[55] => 2,10
[56] => 2,35
[57] => 2,80
[58] => 2,40
[59] => 2,70
[60] => 2,25
[61] => 3,40
[62] => 2,55
[63] => 2,30
[64] => 2,65
)
)
我仍然有多个值,如1,0