I am attempting to loop through my "journalEntries" in order to find duplicates. For some reason, it is taking a very long time to finish and return a response to me. Last time I tested it, it took 12 seconds to finish.
$criteria = craft()->elements->getCriteria(ElementType::Entry);
$criteria->section = 'journalArticles';
$criteria->limit = 10;
$copies = array();
for($a = 0; $a < count($criteria); $a++) {
for($b = $a + 1; $b < count($criteria); $b++) {
if($criteria[$a]->title === $criteria[$b]->title) {
array_push($copies, $criteria[$a]->title);
}
}
}
$this->returnJson($copies);
I think it is something I am doing incorrectly within the two for loops. As you can see, I limit the amount of articles to only 10, so something seriously funky must be going on. Any help?