Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To eliminate duplicate SKU values in PHP, you can use the array_unique() function. This function removes all duplicate values from an array and returns an array with the unique values.

Here is a sample code that you can use:

$sku_array = array('1001', '1002', '1003', '1002', '1004', '1001');
$unique_sku_array = array_unique($sku_array);
print_r($unique_sku_array);

In this code, the $skuarray contains the list of SKUs including duplicates. The arrayunique() function is used to remove the duplicates and the resulting array $uniqueskuarray is printed using the print_r() function.

The output of this code will be:

Array (
    [0] => 1001
    [1] => 1002
    [2] => 1003
    [4] => 1004
)

This shows that the duplicates (1002 and 1001) have been removed and only the unique SKUs are left in the $uniqueskuarray.