Skip to content

Instantly share code, notes, and snippets.

@samin
samin / gist:3314475
Created August 10, 2012 14:11
Word wrap
<?php
$string = "Lorem ipsum dolor sit amet, <a href=\"#\">consectetuer adipiscing</a> elit, <strong>tincidunt</strong> ut volutpat.";
$content = "";
$words = preg_split('/\s+/', trim($string));
foreach ($words as $word) {
$content .= '<span>'.$word.'</span>';
}