$str = "<b> FLYDANNA® HEADWRAP </b> <ul> <li type=\"circle\"><i> Sensational headwrap made from 6 pieces of fabric to fit the contours of your head perfectly </i> <li type=\"circle\"><i> Strong yet lightweight cotton wrap can be folded up and stored almost anywhere-;pocket, purse, backpack ... you name it! </i> <li type=\"circle\">";
此代码应该实现以下功能:
$str = strip_tags( $str );
$str = preg_replace( '/\s+/', ' ', $str );
$words = array_reverse( explode( ' ', $str ) );
foreach ( $words as $k => $s ) {
if ( preg_match( '/\b[A-Z]{2,}\b/', $s ) ) {
$words[$k] = $s . "--";
break;
}
}
$str = trim( join( ' ', array_reverse( $words ) ) );