Check if arrays equal each other


/ Published in: PHP
Save to your folder(s)

Checks if two given arrays equal each other as php doesn't have a built in function for this.


Copy this code and paste it in your HTML
  1. function arraysEqual(arr1, arr2) {
  2. if(arr1.length !== arr2.length)
  3. return false;
  4. for(var i = arr1.length; i--;) {
  5. if(arr1[i] !== arr2[i])
  6. return false;
  7. }
  8. return true;
  9. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.