PHP JSON解碼,如何ingore重複值?在我的情況下,如果$data->a
和$data->b
是重複的,只打印第一個出現的值。PHP JSON解碼ingnore重複值
[
{"a":"1","b":"2","c":"content1"},
{"a":"1","b":"3","c":"content2"},//print
{"a":"1","b":"3","c":"content3"},//duplicate "a":"1","b":"3", do not print
{"a":"2","b":"1","c":"content4"},
{"a":"2","b":"2","c":"content5"},//print
{"a":"2","b":"2","c":"content6"},//duplicate "a":"2","b":"2", do not print
{"a":"2","b":"3","c":"content7"}
]
這不是一件容易的array_unique()
可以工作,請求幫助,謝謝。
看一看http://www.php.net/array_filter – migg