I trying to break long text.
The text look like this: Inquire about space/Enter Library. The text is currently separated using the slash. So we can use the / to tell the code where to break though I don’t mind using character count to break the text (preferable) because the text doesn’t change. The div containing this text is referenced by the id #npali
Output should look like this
Inquire about space<br>
Enter Library
I am unable to get this to work. I was wondering if a PHP alternative would be available to help me achieve this.
Please help if you might know the fix.
Advertisement
Answer
This can be done with the explode() See more: https://www.php.net/manual/en/function.explode.php
An example:
function slash2br($str){
  $parts = explode("/", $str);
  return implode("<br>", $parts);
}
You could also preg_replace() and replace the / with <br>.