- print_r: documentation ( source)
- explode: documentation ( source)
<?php
$str = "device_id=LA14011269&card_number=1073741835&mpb=1000&trans_time=1429443693&sessionId=1073741835LA140112691429443693&checksum=4";
echo checkBcc($str,4);
function checkBcc($str, $check_sum) {
$i=0;
$checksum = 0;
$result = false;
$len = strlen($str);
echo " str:".$str;
$pBuf = explode($str);
print_r($pBuf);
for ($i = 0; $i < $len-2; $i++) {
$checksum ^= $pBuf[$i];
}
echo "checksum:". $checksum;
if ($checksum == $check_sum) {
$result = true;
}
return $result;
}
?>