Note that using key($array) in a foreach loop may have unexpected results. When requiring the key inside a foreach loop, you should use:foreach($array as $key => $value)I was incorrectly using:<?phpforeach($array as $value){ $mykey = key($array);}?>and experiencing errors (the pointer of the array is already moved to the next item, so instead of getting the key for $value, you will get the key to the next value in the array)CORRECT:<?phpforeach($array as $key => $value){ $mykey = $key;}A noob error, but felt it might help someone else out there.