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);

Link to comment
Share on other sites

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"));

Link to comment
Share on other sites

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"));

Link to comment
Share on other sites

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,

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.