mikelmao Posted December 30, 2008 Share Posted December 30, 2008 Hey, How do i get a max char on a news system? Like the max char is 130. after that theres a Read More.. Button. PLease help me out. Thx Link to comment https://forums.phpfreaks.com/topic/138812-max-char/ Share on other sites More sharing options...
Jabop Posted December 30, 2008 Share Posted December 30, 2008 <?php $string='asdfasdfasdfasdfadfasdfasdfadfadfadfasdfadfadfasdfadfadfsdfsdfsdfafasdsdfsdfsdfsdfdf'; if (strlen($string)>130) { echo substr($string, 0, 130) . ' read more omg click here'; } else { echo $string; } ?> Link to comment https://forums.phpfreaks.com/topic/138812-max-char/#findComment-725852 Share on other sites More sharing options...
ucffool Posted December 30, 2008 Share Posted December 30, 2008 I would also add a query string variable on the 'read more' link like ?disp=all Then on the same page you can alter the code from Jabop: <?php $string='asdfasdfasdfasdfadfasdfasdfadfadfadfasdfadfadfasdfadfadfsdfsdfsdfafasdsdfsdfsdfsdfdf'; $disp = $_GET['disp']; if (strlen($string)>130 && !$disp=='full') { echo substr($string, 0, 130) . ' read more omg click here'; } else { echo $string; } ?> Link to comment https://forums.phpfreaks.com/topic/138812-max-char/#findComment-725896 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.