I hope I'm understanding this correctly. I'm assuming that you are saying that you want to store the entire "if" statement you mentioned in your second code block into a string variable. Is that correct?
If so, here is all you need to do:
PHP Code:
function recValues(){
$contents_of_page = file_get_contents('../bible1.html');
preg_match_all("#<td.*>(.+)</td#Ui", $contents_of_page, $tdInnerHTML);
$totaltds = count($tdInnerHTML[1]);
$line = 0;
$strLine = array();
for($k=0; $k < $totaltds; $k++){
if($k % 10 == 0){
print("line ");
$strLine[$line] = '
if($k % 10 != 0){
$j = 0;
$tdValues = array();
$tdValues[$j] = $tdInnerHTML[1][$k];
print("\'");
print("<span style=\'font-weight: bold; color: red\'>".$tdValues[$j]."</span>");
//print($tdInnerHTML[1][$k]);
if($k % 10 == 9){
print("\'<br />\n");
}else{
print("\', ");
}';
}
//return $tdValues[$j];
$j++;
$line++;
}
}