$array1 = array(1,1,1);  
$array2= array(1,5,9,2,2,1);
I need to compare $array2 with $array1 and if $array2 has the same identical values should return true, otherwise should be returning false. In this case it should return false
$array1 = array(1,1,1);  
$array2= array(1,5,9,2,2,1);
I need to compare $array2 with $array1 and if $array2 has the same identical values should return true, otherwise should be returning false. In this case it should return false
 On
                        
                            
                        
                        
                            On
                            
                                                    
                    
                if ( $array1 == $array2 ) {
    return true;
}
else{
    return false;
}
Note: keys must be same too.
To check only values:
if(!array_diff($array1, $array2) && !array_diff($array2, $array1)) 
   return true;
 On
                        
                            
                        
                        
                            On
                            
                                                    
                    
                You can use the == and === operators.
$array1 == $array2 only checks if the two arrays contain the same key/value pairs and $array1 === $array2 also checks if they are in the same order and if they are of the same type.
See the PHP manual.
Well thanks @Shadowfax for trying help but i made the solution, so i post here if anyone have the same problem..