It is my understanding that using isset to prevent duplicate values from being inserted into an array is the best method with regard to memory consumption, resource usage and ease of code processing. I am currently using the array_count_values, like this:
$XMLproducts = simplexml_load_file("products.xml");
foreach($XMLproducts->product as $Product) {
if (condition exists) {
$storeArray[] = (string)$Product->store; //potentially several more arrays will have values stored in them
}}
$storeUniques = array_count_values($storeArray)
foreach ($storeUniques as $stores => $amts) {
?>
<a href="webpage.php?Keyword=<?php echo $keyword; ?>&features=<?php echo $Features; ?>&store=<?php echo $stores; ?>"> <?php echo $stores; ?> </a> <?php echo "(" . ($amts) . ")" . "<br>";
}
How would prevent duplicate values from being inserted into an array (similar to the above) using ISSET? And is there a big performance difference between the 2 if the XML file being parsed is very large (5-6MB)?
array_unique
? – Anthony Apr 11 at 0:55