FidelGonzales Posted May 13, 2010 Share Posted May 13, 2010 I have lurked this site for several years, usually answering my questions through extensive use of the search function. So, finally, here's my first post. On a shopping cart, for the purpose of design layout consistency, I need to reduce the display of the product name text character count. Currently, the character count is only limited by the limitations listed in the database. That limit of 300 characters is fine, but for specific pages in the template, I need the character count limit to be somewhere around 21. Below are a few of the options I have tried. None have worked. I would appreciate any assistance. Any suggestions? Thanks. ORIGINAL CODE <td align="center" valign="top"> <strong><a title="<?php echo $product_name ?>" href="<?php echo $product_flypage ?>"><?php echo $product_name ?><br> <?php echo $product_sku ?></a> </strong></td> WORD LIMIT - Renders the number 4 <td align="center" valign="top"> <strong><a title="<?php echo $product_name ?>" href="<?php echo $product_flypage ?>"><?php echo $product_name; $numwords = 4 ?><br> <?php echo $product_sku ?></a> </strong></td> CHARACTER LIMIT - Renders the number 50 <td align="center" valign="top"> <strong><a title="<?php echo $product_name ?>" href="<?php echo $product_flypage ?>"><?php echo $limit = 50; $product_name ?><br> <?php echo $product_sku ?></a> </strong></td> Link to comment https://forums.phpfreaks.com/topic/201597-character-count-limit-in-display-output/ Share on other sites More sharing options...
FidelGonzales Posted May 13, 2010 Author Share Posted May 13, 2010 Figures that after I searched and searched that immediately after I posted I would figure out how to solve the problem. This isn't pretty, but it does the job. Thanks for looking. <td align="center" valign="top"> <strong><a title="<?php echo $product_name ?>" href="<?php echo $product_flypage ?>"><?php $length = 20 ; $text = "$product_name" ; $display = substr($text, 0, $length) ; echo $display; echo "..." ; ?><br> <?php echo $product_sku ?></a> </strong></td> Link to comment https://forums.phpfreaks.com/topic/201597-character-count-limit-in-display-output/#findComment-1057607 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.