ok
some progress has been made but its not totally correct.....
its going to the next line but not after the precise charactor has been found.
function splitSentence($theWord, $num_words, $x, $y, $handle, $cheque = 0) {
if (!is_numeric($num_words)){
echo "this value is supposed to be a number!";
}
//$theWord = "one two three four five six seven eight";
$text = trim($theWord);
$words = explode(" ",$text);
//get the total number of words
$num_elements = count($words);
// echo "the number of words: ".$num_elements."<BR>";
//figure out the total number of sentences to create
//use the modulus operator to check the remainder of the division of words array by the number of words/sentence
if (($num_elements % $num_words)>0){
//if there are more than an evenly dividable set of numbers
$tot_sent=(int)(($num_elements / $num_words)+1);
}else{
//evenly dividable
$tot_sent=($num_elements / $num_words);
}
//assume from your description that you want to create / fill the sentence array before echoing back to the browser
//fill sentence array
//$yy is a counter
for($yy=0; $yy<$tot_sent; $yy++){
//change the position of the array pointer to continue with the next words in the array
if ($yy>0){
$zz=$num_words*$yy;
}else{
$zz=0;
}
//loop through the $words array and place into sentence
for($qq=(0);$qq<$num_words;$qq++){
// echo $words[$qq];
//fill the sentence
$sentence[$yy]=$sentence[$yy].$words[$qq+$zz]." ";
//echo $sentence[$yy];
} //end $qq for loop
} // end $yy for loop
//show the sentences
for ($ii=0; $ii<$tot_sent; $ii++){
$the_sentence=trim($sentence[$ii]);
// echo $the_sentence."<br>";
$return = chr(13).chr(10);
if (strstr($the_sentence, $return)) {
printer_draw_text($handle, $the_sentence, $x, $y);
$y = $y+100;
} else {
printer_draw_text($handle, $the_sentence, $x, $y);
} // end if
if ($cheque == 0) {
$y = $y+100; // set the coordinates for the next line
} else {
// then cheque must be 1 so increase the gap width for cheque
$y = $y+250;
}
} //close the loop
} // end function