如何从数组中删除重复的条目?

时间:2013-05-24 07:26:16

标签: php mysql

Array (
    [0] => Array (
        [id] => 1
        [userid] => 1
        [sectionid] => 4
        [catid] => 148
        [jobid] => 1
        [jobposition] => Bank Staff reuqired
        [skilllevelid] => 1
        [commitmentid] => 1
        [companyname] => Babkers Bank
        [companysizeid] => 1
        [listedbyid] => 1
        [edate] => 2013-05-24 00:00:00
        [educationlevelid] => 1
        [workexpid] => 1
        [iscvrequired] => 0
        [minaed] => 1800.00
        [maxaed] => 2200.00
        [addcompensation] => 250.00
        [description] => Leading bank in your place requires a junior bank staff.
        [question] => Do you know how to find fake notes?
        [correctans] => Yes
        [incorrectans] => No
        [incorrectansop] => May be
    )
    [1] => Array (
        [id] => 1
        [userid] => 1
        [sectionid] => 4
        [catid] => 148
        [jobid] => 1
        [jobposition] => Bank Staff reuqired
        [skilllevelid] => 1
        [commitmentid] => 1
        [companyname] => Babkers Bank
        [companysizeid] => 1
        [listedbyid] => 1
        [edate] => 2013-05-24 00:00:00
        [educationlevelid] => 2
        [workexpid] => 1
        [iscvrequired] => 0
        [minaed] => 1800.00
        [maxaed] => 2200.00
        [addcompensation] => 250.00
        [description] => Leading bank in your place requires a junior bank staff.
        [question] => Do you know how to find fake notes?
        [correctans] => Yes
        [incorrectans] => No
        [incorrectansop] => May be
    )
)

2 个答案:

答案 0 :(得分:4)

  1. 使用print_r输出您的数组可读
  2. array_unique返回一个没有冗余值的数组 - > http://php.net/manual/en/function.array-unique.php

答案 1 :(得分:0)

以下是来自php.net手册的示例..

<?php
$input = array("a" => "green", "red", "b" => "green", "blue", "red");
$result = array_unique($input);
print_r($result);
?>
The above example will output:
Array
(
[a] => green
[0] => red
[1] => blue
)