justlukeyou Posted May 27, 2012 Share Posted May 27, 2012 Hi, I am trying to limit a single echo so that only 200 characters can only be echoed. <div class="discussionarticlesintroborder"><?php echo $row['intro']; ?></div> This creates an error. <div class="discussionarticlesintroborder"><?php echo $row['intro']; LIMIT 200 ?></div> Quote Link to comment https://forums.phpfreaks.com/topic/263217-limit-individual-echoes/ Share on other sites More sharing options...
.josh Posted May 27, 2012 Share Posted May 27, 2012 echo just echoes whatever value you give it, it has no method or argument for limiting the length of the value. You can wrap your value in a substr call to limit it. Quote Link to comment https://forums.phpfreaks.com/topic/263217-limit-individual-echoes/#findComment-1348981 Share on other sites More sharing options...
silkfire Posted May 27, 2012 Share Posted May 27, 2012 That's what you use the great abundance of string functions you find in PHP for. In this case you are to extract a substring of 200 characters from your string: echo substr($row['intro'], 0, 200) Quote Link to comment https://forums.phpfreaks.com/topic/263217-limit-individual-echoes/#findComment-1349010 Share on other sites More sharing options...
justlukeyou Posted May 27, 2012 Author Share Posted May 27, 2012 Cheers dude. Quote Link to comment https://forums.phpfreaks.com/topic/263217-limit-individual-echoes/#findComment-1349034 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.