Jump to content

[SOLVED] Trimming a php variable


Zepo.

Recommended Posts

^ thats the exact same thing i did.. only yours is less explanitory

 

edit.. i had a booboo in my code

 

use this

$name = "some long string hey";
$max_length = 8; // 8 chars max

if (strlen($name) > $max_length)
{
  $name = substr($name,0,$max_length-1); // i didnt have the $name = on this line the first time lol
  $name .= "..."; // add an ellipses ... at the end
}
else
{}

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.