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)
{ alert("same");} else { alert("not same");}

i got not same. please help me anybody.

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];

if(dd2==dd1 && mm2==mmm1 && yy2==yy1){alert("same");}

both methods not working .

any body help me

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.

Very Gud afternoon.

But tried in javascript.

please help me how to solve this problem 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

Member Avatar

diafol

Moving to js....

Hi Friend very Thanks problem is solved.

Very Very Thanks