Jump to content

Control Number of Lines to 4, and chars per Line 25


jthunder

Recommended Posts

Display 25 chars per line up to 4 lines only. I am doing a little array, but cant figure it out how to control to display the number of lines. I want to control the numer of lines to display to only 4 and 25 characters per line in a table.

 

Somewhere here in the code below :  $types_temp2[] = $categories[$value]['title'];

I need to be able to limit the display to only 25 characters per line up to 4 lines only. Can you help? I did a few tricks but it mostly trunkates characters but continue to the last lines which often runs into about 20 lines.

Thank you for your help.

 

$types_temp = array();
   $types_temp2 = array();
   $types_temp3 = array();

   $types_temp = explode(',', $info['project_types']);
   
   foreach ($types_temp as $value)
   {
      if(isset($categories[$value]['title']))
      {
         $types_temp2[] = $categories[$value]['title'];
      }
   }
   
   $types_temp3 = implode(', ', $types_temp2);

Well what regiemon posted is a starter (for one line).

 

Try this:

$_string="onehundredandonecharacter1111111111111111111111111111111111111111111111111111111111111111111111111120";
$_string_new=substr($_string,0,100);
echo(wordwrap($_string_new,25,"<br />\n"));

Well you aren't echoing anything anywhere so I assume it should be like this:

$types_temp = array();
   $types_temp2 = array();
   $types_temp3 = array();

   $types_temp = explode(',', $info['project_types']);
   
   foreach ($types_temp as $value)
   {
      if(isset($categories[$value]['title']))
      {
         $types_temp2[] = $categories[$value]['title'];
      }
   }
   
   $types_temp3 = implode(', ', $types_temp2);
   
$_string_new=substr($types_temp3,0,100);
echo(wordwrap($_string_new,25,"<br />\n"));

Code is above.

The output is displayed at www.ContractorJoint.com under Category column. Good example is the project called "NOrth Berkeley" where the Job Categories are quite a lot. Thats why I need to trunkate the text as soon as it gets 4 lines already. Thanks,

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.