The Banco do Brasil will make available to you every day a return file with the low of the slips made the day before (the oldest times), through internet banking.
The return file is a normal text file, if I’m not mistaken about the extension .ret. It works as follows, the first line is the header (Header Record) and contains the account data and the purpose of that file, the last is the Trailler Record of the file and only records the end of it, the rest of the file (Detail Record) represents the records that occurred, can represent low, settlement, protest, among others.
To know what each field of the file represents, you have to give a read in the manual of the bank.
Go to the link Manual BB here are all the manuals, what you need is the CBR643 (CNAB400).
Stay tuned because even if no record occurs, BB generates the empty return file, without Record Detail.
Take a look at this repository and run some tests with your return file to see if it works as expected: https://github.com/manoelcampos/Retorno-BoletoPHP
– Henrique Schreiner