Skip to content

Instantly share code, notes, and snippets.

@rodrigoea
Created October 1, 2014 17:14
Show Gist options
  • Save rodrigoea/72b73ae5393be74f7e3b to your computer and use it in GitHub Desktop.
Save rodrigoea/72b73ae5393be74f7e3b to your computer and use it in GitHub Desktop.
Cut text after a number of characters and after the last point.
$text = "Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Nullam id dolor id nibh ultricies vehicula ut id elit. Donec id elit non mi porta gravida at eget metus.";
$split = strpos($text, '. ', 10)+1;
$text1 = wpautop(substr($text, 0, $split));
$text2 = wpautop(substr($text, $split));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment