can you give more info regarding the source of this text you want to format?
it seems like Contenu and Prepresse Fichier are both names for a group
where you have items like 2 encarts , 12 encarts and fourni as items in those groups
The first thing is to detect if the text is a group name or an item, I hope this can be detected from the source where your text comes from.
The second thing is echoing the items correctly.
EDIT:
I do a lot using arrays, created your output using this code:
$text = "Contenu\n\t2 encarts\n\t12 encarts\n\nPrepresse\n\tFichier fourni";
//divide the groups
$groups = explode("\n\n", $text);
//loop groups
foreach ($groups as $group) {
//get group name and items
$items = explode("\n\t", $group);
//loop items,
foreach ($items as $item => $value) {
switch ($item) {
case 0:
//first item is group name
echo $value . " ";
//get the length of this group name to align all items using spaces
$length = strlen($value) + 1;
break;
case 1: //second item is first value, what apears next to the group name
echo $value . "<br>";
break;
default: // other items, where the spaces are the length of the groupname
echo str_repeat(" ", $length) . $value . "<br>";
break;
}
}
//when an entire group is shown, leave an empty space
echo "<br>";
}
?>
shows me this as output:
Contenu 2 encarts
12 encarts
Prepresse Fichier fourni
hope this helps