private static function memodata($data, $fieldInfo) { $out = ''; //Creation of block signature $out .= pack('C', 0) . pack('C', 0) . pack('C', 0) . pack('C', 0x1); /*Create the string of the length of the memo data with fixed string size of 8 chars.If the length is less than * 8 characters then provide a left padding of 0*/ $length = strlen($data); for ($i = strlen($length); $i < 8; $i++) { $length = '0' . $length; } $out .= pack('C', intval($length[0] . $length[1])) . pack('C', intval($length[2] . $length[3])) . pack('C', intval($length[4] . $length[5])) . pack('C', intval($length[6] . $length[7])); //appending data to output $out .= $data; /*Every memo record should be in multiples of the block size. So provide right padding for the memo * records which have lengts not in the multiple of block size*/ $lengthOfOut = strlen($out); $fraction = $lengthOfOut / self::$blockSize - floor($lengthOfOut / self::$blockSize); $requiredlength = $lengthOfOut + (self::$blockSize - $fraction * self::$blockSize); $out = str_pad($out, $requiredlength, pack('C', 0), STR_PAD_RIGHT); $handle = fopen(self::$FPTFileName, 'a'); fwrite($handle, $out); fclose($handle); //Clear the cached statics for fetching the current file size clearstatcache(); $totakeblockno = self::$lastBlockNo; self::$lastBlockNo = self::$lastBlockNo + strlen($out) / self::$blockSize; return str_pad($totakeblockno, 10, " ", STR_PAD_LEFT); }