posted on Feb 03, 2010 at 1:55 p.m. EST in
<?php
function the_nth_sentence($sentence_num = 1) {
if ($sentence_num == 0) {
return false;
}
if ($sentence_num >= 1) {
$sentence_num = $sentence_num-1;
}
$content = get_the_content('',FALSE,'');
$content = apply_filters('the_content', $content);
$content = strip_tags($content);
$pos = strpos($content, '.');
for($i=1; $i<=$sentence_num; $i++) {
$pos = strpos($content, '.', $pos+1);
}
echo '<p>' . substr($content,0,$pos+1) . '</p>';
}
?>
php
1
<?php
function the_nth_sentence ( $sentence_num = 1 ) {
if ( $sentence_num == 0 ) {
return false ;
}
if ( $sentence_num >= 1 ) {
$sentence_num = $sentence_num - 1 ;
}
$content = get_the_content ( '' , FALSE , '' );
$content = apply_filters ( 'the_content' , $content );
$content = strip_tags ( $content );
$pos = strpos ( $content , '.' );
for ( $i = 1 ; $i <= $sentence_num ; $i ++ ) {
$pos = strpos ( $content , '.' , $pos + 1 );
}
echo '<p>' . substr ( $content , 0 , $pos + 1 ) . '</p>' ;
}
?>
copy
|
embed
Hey there! I see you're running Internet Explorer 6.
That's neat. This reminds me of my grandpa. He had this old car that he kept having to fix. He spent so much money on it that he didn't want to get rid of it (even when it stopped running).
You guys should hang out.
Here's a free sports car from Snipt.
0 Comments