Hey everyone,

I just have a question about limiting characters on a web page..I have a blog that I've made on my local server..for test purposes and I was wondering if there is a way to have the same thing display on another part of a page like a blog feed or something. To display like 25-30 characters and then updating every three blog posts when the admin posts a blog..Any advice would be greatly appreciated :)

6 Years
Discussion Span
Last Post by shahbaz13

Try this... but not sure if this could help you as this trims the text

substr($field1a, 0, 45); /* 45 is the characters count you want to show... */

Edited by shahbaz13: n/a

echo substr($string, 0, 45) . '...'; //OK for most uses

//use these (multibyte string functions) if using extended characters - it's safer
echo mb_strimwidth($string, 0, 48,'...', 'UTF-8');

echo mb_substr($string, 0, 45, 'UTF-8') . "...";

@ardav and shahbaz13, sorry but could you explain what those lines of code mean? I'm not familiar with that


substr trims the pice of text line you use

Re: Question about limiting charachters and updating certain things in php

by using

substr("Re: Question about limiting charachters and updating certain things in php", 20);

it outputs...

Re: Question about l

it shows only the first 20 chars...

Edited by shahbaz13: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.