i am writing a php code that displays text from a database.
how would i make the text auto break <br /> after a certain amount of chars?
please help asap. thanks
2 Years Ago
Related Article:need help searching a database in php
is a solved PHP discussion thread by luke noob that has 2 replies, was last updated 2 years ago and has been tagged with the keywords: database, mysql, php, query, search.
The last code i gave wraps nearest word to index 20 of the string
The following code will split the line and insert the break after the 20th character
$text = "lets have a look how many chars before this breaks the string and inputs a line break";
$newtext = chunk_split($text, 20, "<br />\n");
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
lets have a look how many chars before this breaks the string and inputs a line break<br/>
lets have a look how<br />
many chars before t<br />
his breaks the strin<br />
g and inputs a line <br />