how can i reduce the size of a variable printed?

for example, i would like to make it possible to the user to controll the length of a displayed text…

i’m not really sure what you mean… can you be more specific?

for example:

$message is loaded from a textfile.


i want the script to print the script only the number of letters the user sets, for example 5 => the script prints ABCDE

You would use this:

$offset = number user specifies.
$message = the message being cropped.

print substr($message, $offset);

or you can say.

$croppedmsg = substr($message, $offset);
print “$croppedmsg”:

There ya go man :slight_smile: You can also put in a negative number to return a set number of characters from the end of the string towards the front.

thanks man…

and when i want to cut off the end of the message?


thanx m8!!!

with that my shoutbox worx… thanx man, i love you… uhm, ok, its not really love, but… you know what i mean… :smirk:

Just use positive numbers… Or do you mean… If you wanna take off a certain number of characters starting from the end?

I don’t see any direct methods of doing that so I’m guessing it would involve some rigging up to gte it to work right…

I’d suggest just using whatcha got here and Or… You could always do it this way…

$length = strlen($message);
$offset = number inputted by person
$cropnum = $length - $offset;

$croppedmsg = substr($message, $cropnum);

That should do the trick for you.

here’s my shoutbox:

plz post there…