开发者

PHP remove values from a single array? [duplicate]

开发者 https://www.devze.com 2023-01-20 02:12 出处:网络
This question already has answers here: Closed 12 years ago. Possi开发者_开发知识库ble Duplicate:
This question already has answers here: Closed 12 years ago.

Possi开发者_开发知识库ble Duplicate:

How to remove duplicate values from an array in PHP

How can I remove all multiple values for example 55,55 will only be 55 using PHP

Example 1

Array
(
    [0] => 9
    [1] => 2
    [2] => 55
    [3] => 55
    [4] => 9
)

Example 1 should look like example 2 below.

Array
(
    [0] => 9
    [1] => 2
    [2] => 55
)


Use array_unique:

$a2 = array_unique($a);
0

精彩评论

暂无评论...
验证码 换一张
取 消