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 :)

Recommended Answers

All 5 Replies

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... */
Member Avatar for diafol
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

Member Avatar for diafol

Look up the php.net manual. It's useful.

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...
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.