Is there a fast way of doing something like this Compare two arrays with the same value but with a different order in PHP?
I have arrays with potentially same data but in different order and I just need to see whether they are identical.
OK, turns out I get back an object and not an array, I guess...
object(Doctrine\ORM\PersistentCollection)#560 (9) etc.
hmm... Would the easiest way perhaps to iterate over the contents of the collection in order to create my own array and then compare like you all suggested?
Just adding code for my final solution
//Find out if container receives mediasync
$toSync = array();
foreach($c->getVideosToSync() as $v) {
$toSync[] = $v->getId();
}
$inSync = array();
foreach($c->getVideosInSync() as $v) {
$inSync[] = $v->getId();
}
$noDiff = array_diff($toSync, $inSync);
$sameLength = count($toSync) === count($inSync);
if( empty($noDiff) && $sameLength ) {
$containerHelper[$c->getId()]['syncing'] = false;
}
else {
$containerHelper[$c->getId()]['syncing'] = true;
}