Hi,
I have this dynamic string
"ZAN ROAD HOG HEADWRAPS The most popular ZAN headwrap style-features custom and original artwork"
EDIT How can I check all the capital words then if I encountered a ucwords() or title case word then I will automatically add a '--' after the last capital word? Note: The capital words are the product name and the first ucwords() or title case word is the start of the product description.
I have this code right now but its not working at the moment:
<?php
$str = preg_replace( '/\s+/', ' ', $sentence );
$words = array_reverse( explode( ' ', $str ) );
foreach ( $words as $k => $s ) {
if ( preg_match( '/\b[A-Z]{5,}\b/', $s ) ) {
$words[$k] = $s . " --";
break;
}
}
$short_desc = addslashes( trim( join( ' ', array_reverse( $words ) ) ));
?>
Thanks in advance.