codice:<?php $str = '1 1 Primo frase. 1 2 Seconda frase. 10 23 Dodicesima frase.'; $arr = preg_split('#\s*(\d+) (\d+)\s*#', $str, NULL, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); for ($x = 0; $x < count($arr); $x += 3) { echo "<capitolo>{$arr[$x]}</capitolo>"; echo "<verso>{$arr[$x + 1]}</verso>"; echo "<testo>{$arr[$x + 2]}</testo>\n"; }