Jump to content

a better way to do this?


aebstract

Recommended Posts

I was wondering if anyone knew of a better/shorter/cleaner way to do the following:

 

$article = substr($article, 0, 1000);
$dotpos = strrpos($article, '.');
$article = substr($article, 0, $dotpos) . '..';

 

Basically shortens the string down to 1000 characters, then finds the last period in the string, shortens it down again to that period and then adds .. on the end. I bet there is a way to do it in 1 line?

Link to comment
https://forums.phpfreaks.com/topic/192947-a-better-way-to-do-this/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.