Hi, I have a website in PHP and mySQL. I'm writting some articles with large text. How i can split automatically the text by 8000 characters per field. Now i have 3 textareas and i'm splitting the text manually. This is my query: $sql="INSERT INTO articles (title, cat, descr, text1, text2, text3, status, mydate) VALUES ('$_POST[title]', '$_POST[cat]', '$_POST[descr]', '$_POST[text1]', '$_POST[text2]', '$_POST[text3]', '$_POST[status]', '$mydate')" OR die(mysql_error()); mysql_query($sql,$con); PHP: Is there a way that i can do it? Thanks in advance
Hi there, I'm not sure if I understood your question correctly, but if this is what you want to do: have one textfield and split the contents of it into 3 seperate texts ( each of max 8000 characters ). If that's the case, something like this should do the job: $text = "some very long text"; $text1 = substr($text, 0, 8000); $text2 = substr($text, 8000, 16000); $text3 = substr($text, 16000, 24000); PHP: or for 'endless' split-ups (in general) it'd be something like this I suppose; $text = "some very long text"; $texts = array(); //split-ups $start = 0; $increase = 8000; while($start < strlen($text)) { if( ($start + $increase) > strlen($text)) { $limit = strlen($text); }else{ $limit = $start + $increase; } $texts[] = substr($text, $start, $limit); $start += $increase; } PHP: but I'd still be curious why you'd want to do this ( if I understood you correctly ). Let me know if I misunderstood or if you have any further questions, Cheers.
I want to use one textarea only. Now i'm using 3 textareas to split the text manually if it's more than 8000 characters. I think that the first example is ok. Thank you.