/// This is the message used to test the decoder $message = "0x0152414435212135463170524144352122355631704B4C5F472122367B294855444A54372B457721544B210452414435212335562F264B4C5F47212336 7B294855444A50372B46212155213B0452414435212435562F2652414435212535562F264B4C5F472124367B294855444A4E372B457921552456047077725 821473E233C6D21215A4C027077725821473E233C6D21215A4C"; // Remove the "0x", which isn't important $message = substr($message, 2); // Next, we check to see if the message has the non-control characters // at the end or "only" $controlcheck = substr($message, -2); if ($controlcheck != '02' && $controlcheck != '03' && $controlcheck != '04' && $controlcheck != '05'){ $max = 10; $smaller = 20; $length = strlen($message) / 2; echo $length; while ($length > $max){ // Another message inside (or multiple) $smallermessage[] = substr($message, 0, $smaller); $msg = substr($message, $smaller); $length = strlen($msg) / 2 - 1; } }