0) { $sentance_array = str_split($sentence); foreach($sentance_array as $key=>$letter) { // Is this the first value for the checksum? If ($checksum === false) { // Yes. Set the checksum to the value $checksum = $letter; } Else { // No. XOR the checksum with this character's value $checksum = $checksum ^ $letter; } } // return checksum as hexdecimal string return sprintf('%02X', ord($checksum)); } // return boolean FALSE if no characters to evaluate return false; } // example useage echo get_NMEA_checksum($_GET['q']); ?>