Take first 100 characters

Home Forums How To Take first 100 characters

This topic contains 0 replies, has 1 voice, and was last updated by  wyoacx 3 months, 3 weeks ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #1698

    wyoacx
    Participant

    here is an easier way to take x number of characters and without cutting any words at the end it in the middle so your words will always be complete at the end……

    ****************************
    function truncate($text, $length) {
       $length = abs((int)$length);
       if(strlen($text) > $length) {
          $text = preg_replace("/^(.{1,$length})(\s.*|$)/s", '\\1...', $text);
       }
       return($text);
    }
    $string = truncate($WhatEver, 100); 	
    *****************************
    • This topic was modified 3 months, 2 weeks ago by max max.
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.