for debugging i changed the code slightly and mode only one or two modifications to the substr code. it seems to be working now for me.
<?php
$contents = "abdigekddd,,gkdjeigndjeighwuqkdngeuslgntrrlshngie[64512684637745235489";
//$filename = "my_file.txt";
//$filesize = filesize($filename);
//$fd = fopen ($filename, "rb");
//$contents = fread ($fd, $filesize);
$str_len= strlen($contents);
$record_length = 10 ;
$my_records = $str_len/$record_length ;
for($u=0; $u < $my_records ; $u++){
$init_sub = $u * ($record_length);
if ($u > 1) { $init_sub = ($u * $record_length);}
$end_sub = $record_length ;
$my_record_string = substr($contents, $init_sub, $end_sub);
$my_record_string_length = strlen($my_record_string);//must be = $record_length,but it is not so....
echo $my_record_string . "\n";
}
?>
given the contents in that variable, the output was:
abdigekddd
,,gkdjeign
djeighwuqk
dngeuslgnt
rrlshngie[
6451268463
7745235489
ech line 10 chars, from start of the string to the end