You can either loop through the arrays or convert them to string and then compare. This tutorial provides several fast methods of comparing two arrays.
In this snippet, we are going to figure out how to successfully determine the first and last iteration in a foreach loop with the help of PHP.
Here is a short tutorial where you can find three helpful methods allowing to find the foreach index with the help of PHP.
Read this tutorial and learn about several methods used for detecting the property values of an object without knowing the key based on specifications.