I was reworking on the scripting.
I think I know what it's doing though I did these changes. I put these outside the While loop:
PHP Code:
function highlight ( $str, $words )
{
if ( is_array( $words ) ) {
$words = array_map( 'preg_quote', $words );
$words = join( $words, '|' );
} else {
$words = preg_quote( (string)$words );
}
$re = '<span style="color:blue;font-weight:bold;">$1</span>';
return preg_replace( '/\b(' . $words . ')\b/i', $re, $str );
}
function thewords(){
for ($j=0; $j < count($newSearchTheseArr); $j++){
echo $newSearchTheseArr[$j].", ";
}
}
I created
thewords function to set the array of words (does it work this way?)
Then:
PHP Code:
while($row = mysql_fetch_array($result)){
echo "<span id='regular[]' style='padding: 5px;'>";
echo "<span style='font-weight: bold;'>".$row["book_title"]." ".$row["chapter"].":".$row["verse"]." ";
echo "</span>\n";
$words = array(thewords());
$str = $row['text_data'];
var_dump( highlight( $str, $words ) );
echo "<br />\n";
}
I get the words outside the span tags:
Code:
shall<span style="color: blue; font-weight: bold;"></span>
<span style="color: blue; font-weight: bold;"></span>be
<span style="color: blue; font-weight: bold;"></span>
<span style="color: blue; font-weight: bold;"></span>called
<span style="color: blue; font-weight: bold;"></span>
<span style="color: blue; font-weight: bold;"></span>Woman
<span style="color: blue; font-weight: bold;"></span>,
<span style="color: blue; font-weight: bold;"></span>because
<span style="color: blue; font-weight: bold;"></span>
<span style="color: blue; font-weight: bold;"></span>she
<span style="color: blue; font-weight: bold;"></span>
<span style="color: blue; font-weight: bold;"></span>was
<span style="color: blue; font-weight: bold;"></span>
<span style="color: blue; font-weight: bold;"></span>taken
<span style="color: blue; font-weight: bold;"></span>
<span style="color: blue; font-weight: bold;"></span>out
<span style="color: blue; font-weight: bold;"></span>
<span style="color: blue; font-weight: bold;"></span>of
<span style="color: blue; font-weight: bold;"></span>
<span style="color: blue; font-weight: bold;"></span>Man
<span style="color: blue; font-weight: bold;"></span>."