How do i sum up this

can anyone help me on this please how can i Sum up 40 to 2A ?


40 40 51 32 35 2C 33 35 33 33 35 38 30 31 37 37 38 34 30 36 32 2C 41 31 30 2A

to get


056A

Thank you in advance.

I was bored so came up with this.

<?php
$hexvals="40 40 51 32 35 2C 33 35 33 33 35 38 30 31 37 37 38 34 30 36 32 2C 41 31 30 2A";
$hexarr=explode(" ",$hexvals);
$sum=0;
foreach ($hexarr as $hexval) {
    $decval=hexdec($hexval);
    $sum+=$decval;
}
$hexsum=strtoupper(str_pad(dechex($sum),4,0,STR_PAD_LEFT));
echo $sum . " >>> " . $hexsum;
?>

Try to do your own homework projects in future. :wink:

Hi,Thank you so much for this…:slight_smile:

Hi, can I asked how can i get the low byte 056A ?Is this possible in php,I have no idea on this.

Thank you in advance.