danny44 Posted September 5, 2010 Share Posted September 5, 2010 Hello! Im new here and want to start my new php carreer Well, I'm already working quite hard, but now I don't know what to do I've got it so far: <?php echo html::chars($message->text); ?> Is there any way I could modify the output, so it just displays the first 20 characters or so? Thank you all very much! Quote Link to comment Share on other sites More sharing options...
PaulRyan Posted September 5, 2010 Share Posted September 5, 2010 So you're wanting the leading line for a block of text? Similiar to use in forums ect... You could use the following to stop at 20 characters outputted $leadingLine = trim(substr($YourTextString,0,20)); Try the above, and tell me how it goes. Regards, Paul. Quote Link to comment Share on other sites More sharing options...
danny44 Posted September 5, 2010 Author Share Posted September 5, 2010 I'm just too stupid to implement it i think <?php echo html::chars($message->text); $leadingLine = trim(substr($message->text,0,4)); ?> This does not change anything, i changed it to 4 to see if it does anything atleast, but it does not ): Quote Link to comment Share on other sites More sharing options...
PaulRyan Posted September 5, 2010 Share Posted September 5, 2010 Ohh right, what text does "html::chars($message->text)" contain? Try this, i'm not 100% sure if it will work but it's worth a go? $leadingLine = trim(substr(html::chars($message->text),0,4)); Then when calling the text use <?PHP echo $leadingLine;?> or something like that, depending on your situation. Thanks, Paul. Quote Link to comment Share on other sites More sharing options...
danny44 Posted September 5, 2010 Author Share Posted September 5, 2010 Thank you very much Paul, it works! Took me some time, but hey, I have to start somewhere ... it's working now! Is there any way to add a specified text after the text, if it gets cutted? For example if the text gets cutted, he adds "read on" to the text: In this article I tell you someth read on Maybe there is some easy way to do this Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.