Fsoft Posted May 30, 2008 Share Posted May 30, 2008 Hi, There is a text area in my script / form. In the text area when some thing is written, It goes just long and long and Cuts the entire Page. My Text area value is colleted by using this <?php $details = $_POST["details"]; ?> NOW I want that Before writing the data to file. This variable details must be run by a test. What test? Well After each 50 charters in the $details, It must insert an auto <br> inside of it. And it must continue until it's done with all the charters. For example, If the $details come with 200 Charters. It must enter 4 <br> each after every 50 Charters. HMM Looks little complicated to me. Thanks a lot Badly waiting for answer FAISAL! Link to comment https://forums.phpfreaks.com/topic/108046-after-50-chars-an-auto-break/ Share on other sites More sharing options...
BillyBoB Posted May 30, 2008 Share Posted May 30, 2008 Are you talking about the textarea has to break after 50 char. or the text when displayed on the webpage? Link to comment https://forums.phpfreaks.com/topic/108046-after-50-chars-an-auto-break/#findComment-553808 Share on other sites More sharing options...
Fsoft Posted May 30, 2008 Author Share Posted May 30, 2008 The text of text area must Break after 50 chars. And get onto a new line as it does in the editor of here SMF. When we are typing. We don't have to go down, it automatically Breaks I want that .. THANKS for the answer though Link to comment https://forums.phpfreaks.com/topic/108046-after-50-chars-an-auto-break/#findComment-553810 Share on other sites More sharing options...
BillyBoB Posted May 30, 2008 Share Posted May 30, 2008 Well I don't believe that the textarea can alter the looks of the text at a later point. You must do this in two separate areas. First you must make the textarea have 50 cols. <textarea cols="50" rows="7"> Then later you must put in a break every 50 chars. The easiest way is to use the php function wordwrap. <?php $string = wordwrap($text, 50); ?> That should do it for you. Link to comment https://forums.phpfreaks.com/topic/108046-after-50-chars-an-auto-break/#findComment-553817 Share on other sites More sharing options...
Fsoft Posted May 30, 2008 Author Share Posted May 30, 2008 Thanks a lot boss I use this code ; <?php $form = "<form method=\"post\" action=\"test.php\"> Name : <input name=\"name\" type=\"text\" size=\"20\"> <input name=\"submit\" type=\"submit\" value=\"submit\"> </form> "; if($_POST["submit"] == submit){ $text_out = wordwrap($_POST["name"], 50); echo $text_out; }else { echo $form; } ?> BUT still, When I insert a string into the text and Put a long line, It don't put a <br> after the 50 charters BUT Just appends the page and Increases the page ( Ok, If this don't work this .. Tell me an easy code that from a line or MySQL we get a text that is a line (300) charters. I want to print it out BUT I want a <br> after 50 chars Thanks a lot FAISAL! Link to comment https://forums.phpfreaks.com/topic/108046-after-50-chars-an-auto-break/#findComment-553841 Share on other sites More sharing options...
DarkWater Posted May 30, 2008 Share Posted May 30, 2008 Even in between words? O_O $post = implode("<br />", str_split($post, 50)); Link to comment https://forums.phpfreaks.com/topic/108046-after-50-chars-an-auto-break/#findComment-553844 Share on other sites More sharing options...
Fsoft Posted May 30, 2008 Author Share Posted May 30, 2008 Thanks dark water, I use this code, But still no change <?php $form = "<form method=\"post\" action=\"test.php\"> Name : <input name=\"name\" type=\"text\" size=\"20\"> <input name=\"submit\" type=\"submit\" value=\"submit\"> </form> "; if($_POST["submit"] == submit){ $post1 = $_POST["name"]; $post = implode("", str_split($post1, 50)); echo $post; }else { echo $form; } ?> FAISAL! Link to comment https://forums.phpfreaks.com/topic/108046-after-50-chars-an-auto-break/#findComment-553853 Share on other sites More sharing options...
runnerjp Posted May 30, 2008 Share Posted May 30, 2008 i would also be greatful fo sum answer lol as i never thought about this yet Link to comment https://forums.phpfreaks.com/topic/108046-after-50-chars-an-auto-break/#findComment-553864 Share on other sites More sharing options...
DarkWater Posted May 30, 2008 Share Posted May 30, 2008 Forgot to put code tags. $post = implode("<br />", str_split($post1, 50)); There. Link to comment https://forums.phpfreaks.com/topic/108046-after-50-chars-an-auto-break/#findComment-553865 Share on other sites More sharing options...
runnerjp Posted May 30, 2008 Share Posted May 30, 2008 or you could use this <?php $text = wordwrap($text, 35, "**"); //Where $text is your text that was submitted, 35 is the # of chars before a word wrap, and ** is the break(default is \n) $arr = explode('**', $text); ?> Link to comment https://forums.phpfreaks.com/topic/108046-after-50-chars-an-auto-break/#findComment-553901 Share on other sites More sharing options...
Fsoft Posted May 30, 2008 Author Share Posted May 30, 2008 Wao, Very well done .. But now very small problem the text goes out like this ; Details : This is a test message, If you can see this message, it mean s your Buy and Sell system is Installed successfully, Plesae delete /install.php and go to /moderate.php to moderate.You can delete this query once you get into your moderation. Fo r more info go and open configuration.php... The password of Admin Access must be inserted inside of your configuration. php on the variable admin_pass.... Enjoy the Script. Best W ishes -> FAISAL SHAH! Is it not possible to put break only when we get a " " space. ?? thanks > I hope it's possible to make teh script perfect. Or it will look bad Thanks! Link to comment https://forums.phpfreaks.com/topic/108046-after-50-chars-an-auto-break/#findComment-553907 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.