How to show only certain words in PHP?

If I have the code


$a=Hello this is a text.
echo $a;

This will return the whole string,

Hello this is a text.

But I want it to display just like upto whatever characters I want, say upto 10 characters.

so it should return when it limited to 10 characters

Hello this

How to do this?


$a='Hello this is a text.';
echo substr($a, 0, 10);

Here it is in da manual: [fphp]substr[/fphp]

:slight_smile:

PS. Note the quotes around the string

Thank you sir.