<?php 
// A Simple PHP program to compute 
// sum of bitwise OR of all pairs 

// Returns sum of bitwise OR 
// of all pairs 
function pairORSum($arr, $n) 
{ 
	
	// Initialize result 
	$ans = 0; 

	// Consider all pairs 
	// (arr[i], arr[j) such that 
	// i < j 
	for ( $i = 0; $i < $n; $i++) 
		for ( $j = $i + 1; $j < $n; $j++) 
			$ans += $arr[$i] ^ $arr[$j]; 

	return $ans; 
} 

	// Driver Code 
	$arr = array( 5, 9, 7, 6 ); 
	$n = count($arr); 
	echo pairORSum($arr, $n) ; 

// This code is contributed by anuj_67. 
?> 
