ATTENTION!! ... We just launched this forum recently, so not much is on it yet. JOIN TODAY!

How to Truncate Text

Everything that has to to do with programming using PHP
Post Reply
User avatar
PixelinkMedia
Site Admin
Posts: 50
Joined: Mon Apr 08, 2019 2:20 pm
Contact:

How to Truncate Text

Post by PixelinkMedia » Mon Apr 22, 2019 7:02 pm

Only display a small portion of a long string...

Code: Select all


$text = "long text that should be truncated";
echo substr($text, 0, 15);

This code will begin at 1st char (0) and only get 15 char.
The output would be...
"long text that"

FYI... this also includes white spaces.
My Site: Pixelink Media • Windows 7 • 10G RAM • NIV-GForce GT 640 Graphics Card
Affinity (Designer/Photo/ • CorelDraw • Blender • HitFilm • Saola (web animation/interactive) • MagicaVoxel
Lazarus (Free Pascal) • .NET Framework (discontinued for now) • PHP • Html/CSS • Javascript • mySQL/SQLite
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest