Jump to content

Recommended Posts

I'm not sure why this is not working so I thought I would post it here. I'm just looping through information that I am getting from a database with a while loop and displaying it in HTML. The problem that I found out is that some of the text has no breaks in it and so it would stretch the cells out pass what I would like. It was suggested to me that I use wordwrap to force the text to wrap as I would like it.

 

$title = wordwrap($row['Job_Title'], 10, "<br />\n");

 

This is what I came up with, I assume that it would count over 10 chars and put in a break. The thing is it's not doing that, is there something wrong with my syntax of it?

 

Thanks for looking at this for me :)

 

Stephen

Link to comment
https://forums.phpfreaks.com/topic/146869-solved-wordwrap-help/
Share on other sites

I think the better solution is to set the width of your cells so they cannot be broken.

 

<table width="500">
<tr>
<td width="100">info</td>
<td width="100">info</td>
<td width="100">info</td>
<td width="100">info</td>
<td width="100">info</td>
</tr>
</table>

 

This way, the text can never break 100px in size for each cell...

 

Hope that helps!

Link to comment
https://forums.phpfreaks.com/topic/146869-solved-wordwrap-help/#findComment-771050
Share on other sites

It could be a few words and would most likely contain /n in it.

 

The \n is where the issue arises, unfortunately. But as long as the other method works you are good. I just figured it would be good for you to have an explanation why it was not working properly. The \n to wordwrap is already separating the string.

 

Alternatively, if \n is meant to do that you might want to look into nl2br as that may be an answer.

Link to comment
https://forums.phpfreaks.com/topic/146869-solved-wordwrap-help/#findComment-771178
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.