Jump to content

Recommended Posts

Hi! I currently have some text that I want to add a line break to every 100 characters.
The problem I have is that the text is inside of a shortcode and I am not sure how to wordwrap it from inside that shortcode.

Here's the code:

<?php echo do_shortcode('[myshortycode]This is the text I want to add line breaks to[/myshortycode]') ?>

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

Wouldn't it be better to just do that with a css fixed-width container so the text wraps naturally? If you hard chop the text at 100 chars, it will, most likely, cut some words in half. I'd assume you'd want it to only break on spaces and not in the middle of a word. That can of course be done with PHP, but a fixed-width container is a lot simpler.

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