I have an array resulted from a function but can't figure out how to set it properly:
The function is:Code:Array ( [0] => [1] => <br /> [2] => <span class="goToBookChapter" style="font-weight: bold;">Genesis 29:2</span><br /> [3] => <br /> [4] => And he <span class="" id="" style="color:MediumTurquoise; font-weight:bold;">looked</span>, and <span class="" id="" style="color:DarkRed; font-weight:bold;">behold</span> a well in the field, and, lo, there were three <span class="" id="" style="color:Teal; font-weight:bold;">flock</span>s of sheep lying by it; for out of that well they watered the <span class="" id="" style="color:Teal; font-weight:bold;">flock</span>s: and a <span class="" id="" style="color:; font-weight:bold;">great</span> stone was upon the well's mouth.<br /> [5] => <br /> [6] => <span class="goToBookChapter" style="font-weight: bold;">Exodus 2:16</span><br /> [7] => <br /> [8] => Now the <span class="" id="" style="color:green; font-weight:bold;">priest</span> of <span class="" id="" style="color:PaleGreen; font-weight:bold;">Midian</span> had seven daughters: and they came and drew water, and filled the troughs to water their <span class="" id="" style="color:Magenta; font-weight:bold;">father</span>'s <span class="" id="" style="color:Teal; font-weight:bold;">flock</span>.<br /> [9] => <br /> [10] => <span class="goToBookChapter" style="font-weight: bold;">Exodus 3:1</span><br /> [11] => <br /> [12] => Now <span class="" id="" style="color:red; font-weight:bold;">Moses</span> kept the <span class="" id="" style="color:Teal; font-weight:bold;">flock</span> of <span class="" id="" style="color:blue; font-weight:bold;">Jethro</span> his <span class="" id="" style="color:Magenta; font-weight:bold;">father</span> in law, the <span class="" id="" style="color:green; font-weight:bold;">priest</span> of <span class="" id="" style="color:PaleGreen; font-weight:bold;">Midian</span>: and he led the <span class="" id="" style="color:Teal; font-weight:bold;">flock</span> to the <span class="" id="" style="color:orange; font-weight:bold;">backside</span> of the <span class="" id="" style="color:purple; font-weight:bold;">desert</span>, and came to the <span class="" id="" style="color:Pink; font-weight:bold;">mountain</span> of God, even to <span class="" id="" style="color:YellowGreen; font-weight:bold;">Horeb</span>.<br /> [13] => <br /> [14] => <span class="goToBookChapter" style="font-weight: bold;">Exodus 3:2</span><br /> [15] => <br /> [16] => And the <span class="" id="" style="color:Sienna; font-weight:bold;">angel</span> of the LORD <span class="" id="" style="color:aqua; font-weight:bold;">appeared</span> unto him in a <span class="" id="" style="color:Gray; font-weight:bold;">flame</span> of fire out of the <span class="" id="" style="color:LightBlue; font-weight:bold;">midst</span> of a bush: and he <span class="" id="" style="color:MediumTurquoise; font-weight:bold;">looked</span>, and, <span class="" id="" style="color:DarkRed; font-weight:bold;">behold</span>, the bush <span class="" id="" style="color:; font-weight:bold;">burned</span> with fire, and the bush was not <span class="" id="" style="color:; font-weight:bold;">consumed</span>.<br /> [17] => <br /> [18] => <span class="goToBookChapter" style="font-weight: bold;">Exodus 3:3</span><br /> [19] => <br /> [20] => And <span class="" id="" style="color:red; font-weight:bold;">Moses</span> said, I will now turn <span class="" id="" style="color:; font-weight:bold;">aside</span>, and see this <span class="" id="" style="color:; font-weight:bold;">great</span> <span class="" id="" style="color:; font-weight:bold;">sight</span>, why the bush is not <span class="" id="" style="color:; font-weight:bold;">burnt</span>.<br /> [21] => <br /> [22] => <span class="goToBookChapter" style="font-weight: bold;">Exodus 17:6</span><br /> [23] => <br /> [24] => <span class="" id="" style="color:DarkRed; font-weight:bold;">Behold</span>, I will stand before thee there upon the rock in <span class="" id="" style="color:YellowGreen; font-weight:bold;">Horeb</span>; and thou shalt smite the rock, and there shall come water out of it, that the people may drink. And <span class="" id="" style="color:red; font-weight:bold;">Moses</span> did so in the <span class="" id="" style="color:; font-weight:bold;">sight</span> of the elders of Israel.<br /> )
It should be:PHP Code:function getQuery($bigWords){
...
$theresult = array();
$theresult[] = "";
//$theresult[] = $query;
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result)){
$theresult[] .= "<br />\n";
$theresult[] .= "<span class=\"goToBookChapter\" style=\"font-weight: bold;\">".$row['book_title']." ".$row['chapter'].":".$row['verse']."</span><br />\n";
$strText = $row['text_data'];
$COLORS = array('red','Teal','blue','Magenta','green','PaleGreen','orange','purple','Pink','YellowGreen','Sienna','aqua','Gray','LightBlue','MediumTurquoise','DarkRed');
for($m=0; $m < count($bigWords); $m++){
$strText = preg_replace("/(".$bigWords[$m].")/i", "<span class=\"\" id=\"\" style=\"color:".$COLORS[$m]."; font-weight:bold;\">$1</span>", $strText);
}
$theresult[] .= "<br />\n";
$theresult[] .= $strText."<br />\n";
}
return $theresult;
echo "<br /><br />".$query."<br />";
}
echo "Words searched for:<br />\n";
$bigWords = array_values($bigWords);
//to make $k start the $COLORS from 0
$k = 0;
for ($j=0; $j < count($bigWords); $j++){
if($bigWords[$j]!=""){
echo "<span style='font-weight: bold; color: ".$COLORS[$k].";'>".$bigWords[$j]."</span>\n";
if($j!=count($bigWords)-1){
echo " + ";
}else{
//removes the OR from the last line and replaces with the following
//for results of words > 3
echo ".<br />\n";
}
$k++;
}
}
print_r(getQuery($bigWords));
Code:Array ( [0] =><br /><span class="goToBookChapter" style="font-weight: bold;">Genesis 29:2</span><br /><br />And he <span class="" id="" style="color:MediumTurquoise; font-weight:bold;">looked</span>, and <span class="" id="" style="color:DarkRed; font-weight:bold;">behold</span> a well in the field, and, lo, there were three <span class="" id="" style="color:Teal; font-weight:bold;">flock</span>s of sheep lying by it; for out of that well they watered the <span class="" id="" style="color:Teal; font-weight:bold;">flock</span>s: and a <span class="" id="" style="color:; font-weight:bold;">great</span> stone was upon the well's mouth.<br /> [1] => <br /><span class="goToBookChapter" style="font-weight: bold;">Exodus 2:16</span><br /><br />Now the <span class="" id="" style="color:green; font-weight:bold;">priest</span> of <span class="" id="" style="color:PaleGreen; font-weight:bold;">Midian</span> had seven daughters: and they came and drew water, and filled the troughs to water their <span class="" id="" style="color:Magenta; font-weight:bold;">father</span>'s <span class="" id="" style="color:Teal; font-weight:bold;">flock</span>.<br /><br /> [2] => <span class="goToBookChapter" style="font-weight: bold;">Exodus 3:1</span><br /><br />Now <span class="" id="" style="color:red; font-weight:bold;">Moses</span> kept the <span class="" id="" style="color:Teal; font-weight:bold;">flock</span> of <span class="" id="" style="color:blue; font-weight:bold;">Jethro</span> his <span class="" id="" style="color:Magenta; font-weight:bold;">father</span> in law, the <span class="" id="" style="color:green; font-weight:bold;">priest</span> of <span class="" id="" style="color:PaleGreen; font-weight:bold;">Midian</span>: and he led the <span class="" id="" style="color:Teal; font-weight:bold;">flock</span> to the <span class="" id="" style="color:orange; font-weight:bold;">backside</span> of the <span class="" id="" style="color:purple; font-weight:bold;">desert</span>, and came to the <span class="" id="" style="color:Pink; font-weight:bold;">mountain</span> of God, even to <span class="" id="" style="color:YellowGreen; font-weight:bold;">Horeb</span>.<br /> }




Reply With Quote