Jump to content

Limit string length


vividona

Recommended Posts


<?php
$summary = "I am on [url=http://whatever.com/][/url]";
$find = "[url";
$find2 = "[code]";
if (strpos($summary, $find )
{
$ends = "/][/url]";
}
if (strpos($summary, $find2 )
{
$ends2 = "

";

}

$limit = 15;

 

if (strlen($summary) > $limit)

$collective = "$summary $ends $ends2";

      $summary = substr($summary, 0, strrpos(substr($collective, 0, $limit), ' ')) . '...';

      echo $summary;

?>

 

[/code]

Link to comment
https://forums.phpfreaks.com/topic/193858-limit-string-length/#findComment-1020295
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.