[ create a new paste ] login | about

Link: http://codepad.org/yih5j7cl    [ raw code | output | fork ]

PHP, pasted on Oct 12:
<?php

	$GroupOfEight = array(array(5,5,5),array(0,1,3,2,4,5,7,6),array(4,5,6,7,16,12,13,14),array(12,13,15,14,8,9,11,10),array(2,6,14,10,3,7,15,11),array(1,3,5,7,13,15,9,11),array(0,4,12,8,1,5,13,9),array(0,1,3,2,8,9,11,10));
	
	$myStack = array(0,1,3,2,4,1,2,3);
	
	//
	$myStack = array_unique($myStack);
	$searchKeys = array();
	foreach ( $GroupOfEight as $key => $values ) {
		(count(array_intersect($values, $myStack)) == count($myStack)) and $searchKeys[] = $key;
	}
	
	// Output all keys it wound same match
	var_dump($searchKeys);
	
	// OR Output Each Array it found a match
	foreach ( $searchKeys as $key ) {
		var_dump($GroupOfEight[$key]);
	}

?>


Output:
array(1) {
  [0]=>
  int(1)
}
array(8) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(3)
  [3]=>
  int(2)
  [4]=>
  int(4)
  [5]=>
  int(5)
  [6]=>
  int(7)
  [7]=>
  int(6)
}


Create a new paste based on this one


Comments: