<?php
$data = '[xxx] test test[xxx]foobar
more data
[xxx] more data
[xxx] other data []:foo bar
more data here
[xxx] 1234';

foreach(preg_split('/^(?=\[xxx] )/m', $data) as $el) {
	echo preg_replace('/\n(?!$)/', '\\n', $el);
}