0

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

Edited by diafol: Wrong forum

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

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

0

Very Gud afternoon.

But tried in javascript.

please help me how to solve this problem in javascript

0

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

0

Hi Friend very Thanks problem is solved.

Very Very Thanks

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.