I have two arrays arr1 is 2015,03,12
and arr2 is 2015,03,12

how to compare i tryied like this
first method

``````if(arr1==arr2)
``````

second method

``````var dd1 = arr1[2];
var mm1 = arr1[1];
var yy1 = arr1[0];

var dd2 = arr2[2];
var mm2 = arr2[1];
var yy2 = arr2[0];

``````

both methods not working .

any body help me

Edited by diafol: Wrong forum

3
Contributors
5
Replies
13
Views
2 Years
Discussion Span
Last Post by ramsiva

Try use array_diff

``````<?php
\$a1=array("2015","03","12");
\$a2=array("2015","03","13");

\$result=array_diff(\$a1,\$a2);
print_r(\$result);
// returned Array ( [2] => 12 )
?>

while

<?php
\$a1=array("2015","03","12");
\$a2=array("2015","03","12");

\$result=array_diff(\$a1,\$a2);
print_r(\$result);
// returned Array ( )
?>
``````

then we can use if(empty(\$result)) to check if the array is different.

Edited by lps

Very Gud afternoon.

But tried in javascript.

But you posted in PHP section...Is jquery okie for you? As I done some googling and found this jquery code

``````var diff = \$(old_array).not(new_array).get();
``````

and you can check if the diff is emptied also

Moving to js....

Hi Friend very Thanks problem is solved.

Very Very Thanks