1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23:
| <?php
function smarty_keywords( $string ) { if( is_array( $string ) ) $string = implode( ' ', $string ); $string = preg_replace( '/[^a-zA-Z0-9öäüÖÄÜß]/', ' ', $string ); $arr = explode( ' ', $string ); foreach( $arr as $val ) { if( strlen( $val ) > 2 ) $tmp[$val]++; } arsort( $tmp ); $tmp = array_keys( $tmp ); if( count( $tmp ) > 0 ) { $string = mb_strtolower( implode( ', ', $tmp ) ); return trim( $string ); } }
$test = "One of Smartys - primary - design goals is to facilitate the 'separation' of application (code) from presentation."; echo smarty_keywords( $test );
#$smarty->register_modifier( 'keywords', 'smarty_keywords' );
?>
|