Ok totally rewritten and I added some comments
<?
$string ='test this string sentence';
//break string into an array or words
$words = explode(' ',$string);
//get the total number of words in your string
$num_words = count($words);
//declare variable
$first_string = '';
//divide the total # of words by two
$end_of_first_string = ($num_words / 2);
//loop up until the first half
for($i = 0; $i < $end_of_first_string; $i++){
$first_string .= $words[$i] . ' ';
}
//declare variable
$second_string = '';
//fmod is used to find the reminder of a division statement
//this is need if the # of words happen to be odd
//otherwise it would print the middle most word twice
if(fmod($num_words,2) == 1){
$start_of_second_string = ($end_of_first_string + 1);
} else {
$start_of_second_string = $end_of_first_string;
}
//loop to end of words
for($i = $start_of_second_string ; $i < $num_words; $i++){
$second_string .= $words[$i] . ' ';
}
//do what you need to do here with the variables ;)
echo($first_string .' some filler text '.$second_string);
?>
http://mynameissteve.com