I have a array of page numbers:
foreach($elements as $el) {
$pageno = $el->getAttribute("pageno");
echo $pageno ;
}
foreach(array_unique($elements) as $el) {
$pageno = $el->getAttribute("pageno");
echo $pageno ;
}
Since I do not have your data structure, I am providing a generic solution. This can be optimized if we know the structure of $elements
but the below should work for you.
$pageNos = array();
foreach($elements as $el) {
$pageno = $el->getAttribute("pageno");
if(!in_array($pageno, $pageNos))
{
echo $pageno ;
array_push($pageNos,$pageno)
}
}
Basically we are just using an additional array to store the printed values. Each time we see a new value, we print it and add it to the array.