EOT; preg_match_all('#

(.+?)

#is', $body, $matches); switch(count($matches[0])) { case 0: break; case 1: echo $matches[0][0]; break; case 2: echo $matches[0][0].$matches[0][1]; break; default: echo $matches[0][0]."

".$matches[1][1].' Read more »'; break; } ?>"> EOT; preg_match_all('#

(.+?)

#is', $body, $matches); switch(count($matches[0])) { case 0: break; case 1: echo $matches[0][0]; break; case 2: echo $matches[0][0].$matches[0][1]; break; default: echo $matches[0][0]."

".$matches[1][1].' Read more »'; break; } ?>" />

Vote Charlie!

Use PHP to output first two paragraphs of MT entries

Posted at age 23.
Created . Edited .

This is a quick and dirty solution for use in Movable Type templates, but it should work!

<?php
$body = <<<EOT
<$mt:EntryBody encode_php="here"$>
EOT;
preg_match_all('#<p>(.+?)</p>#is', $body, $matches);
switch(count($matches[0])) {
  case 0: break;
  case 1: echo $matches[0][0]; break;
  case 2: echo $matches[0][0].$matches[0][1]; break;
  default: echo $matches[0][0]."<p>".$matches[1][1].' <a href="<mt:EntryPermalink>" class="actionlink">Read more &raquo;</a>'; break;
}
?>