<?php$content = "";$content .= "<html>\n";$content .= "<head>\n";$content .= "<title>#mytitle#</title>\n";$content .= "</head>\n";$content .= "<body>\n";$content .= "#something#\n";$content .= "<textarea name=\"something\">\n";$content .= "#name#\n";$content .= "</textarea>\n";$content .= "#name#\n";$content .= "</body>\n";$content .= "</html>\n";/* first just to make it easier make function left() */function left($string, $count){ return substr($string, 0, $count);}function replace($string) { //your replace function here return $string;}$rplvar = 0; //first to make rplvar 0//ok here we replace the \n with a char sign in the string//the char is chr(13) this stands for return$content = str_replace("\n",chr(13),$content);//first we need to save the spaces and make them in to a char we will use later on again to make it back to a space$content = str_replace(chr(32),chr(160),$content);//now we are going to make this chr(13) in to chr(32)//chr(32) stands for space$content = str_replace(chr(13),chr(32),$content);/* here we go first count the words*/$counter = count(explode(" ", $content));$match = explode(" ", $content); // explode to match$i = 1;for (; ; ) { if ($i > $counter) { break; } $j = $i - 1; // match starts at 0 instead of 1 where count starts at 1 so we need to do minus 1 to get the correct match $myvar = $match[$i]; $myvar = str_replace(chr(160),chr(32),$myvar); //ok we need to return the char 160 back to a space. if ($myvar == "<textarea") { $rplvar = 1; } if ($myvar == "</textarea>") { $rplvar = 0; } if ($rplvar == 0) { echo replace($myvar); } else { echo $myvar; } $i++;}?>