$cleanitem = ''; for ($y=0; $y=(floor(strlen($dirtyitem)/40)-1); $y++) { $cleanitem = $cleanitem . substr($dirtyitem, ($y * 40), 40) . '
'; }