<?php
$products = array(
'CATEGORY' =>
array(
0 => 'book',
1 => 'book',
2 => 'desk',
),
'DESCRIPTION' =>
array(
0 => 'Bar',
1 => 'sdfadasfdasfas',
2 => 'Barrrr',
),
);
echo "Before:\n";
print_r($products);
echo "\nAfter:\n";
$cat_to_index = '';
foreach (array_values(array_unique($products['CATEGORY'])) as $category => $uniq_cat) {
$keys = array_keys($products['CATEGORY'], $uniq_cat);
if (0 < count($keys)) {
// Occur more than once
$cat_to_index .= join(", ", $keys) . "\n";
}
}
print_r($cat_to_index);
?>