I\'m designing an electrical engineering application. However, i\'m stuck on this: I have the following array
The thing that is wrong with your original approach is that you loop through GroupOfEight twice. You have two for-loops.
First you select every array within GroupOfEight and in the second for loop you go through each value of the array.
If you would like to use your original approach, get rid of the extra for loop:
echo "Hello, World!";
$GroupOfEight = array (
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,5,7,6); //Dynamic, gets value by POST method.
for($i=0; $i " . print_r($GroupOfEight[$i], true) . "
==
" . print_r($myStack, true);
}
}
Demo: http://codepad.viper-7.com/0hRNHz
You could accomplish the same with array_diff:
for($i=0; $i " . print_r($GroupOfEight[$i], true) . "
==
" . print_r($myStack, true);
}
}
Demo: http://codepad.viper-7.com/6uLd9L
Update
A related SO post is: Check whether two array values are equal (ignoring order)