Are you sure you want to see all of it? It's just a bunch of if else statements looking for stuff in $key and pushing the results to a different array. Its probably quite messy compared to what a professional could do.
Code: Select all
$j=0;
echo "<div style=\"margin-left: 15%;
margin-right: auto; padding-bottom:100px;
\">";
//start foreach statement to print $key and $value and create hidden div for each result
foreach($foalStringsTotal as $key=>$value){
echo "<p style=\"font-size:20px;\"
onmouseover=\"ShowPart('uniquename$j');\" onmouseout=\"HidePart('uniquename$j');\";
>$key has a $value% Chance of Occuring<br></p>
";
$color=array();
$colorpic=array();
//search $key and if a result is present add that result to one array and the img that goes with that result to another
if (strchr($key,EE)){
$dest = imagecreatefrompng("images/black.png");
imagealphablending($dest, true); // setting alpha blending on
imagesavealpha($dest, true); // save alphablending setting (important)
if (strchr($key,AAt)){
$tmp = imagecreatefrompng("images/bay.png");
array_push($colorpic,$tmp);
array_push($color,"Base Color is Bay Homozygous for Extension and Carries both Seal and Wild-type Alleles at Agouti");
}
elseif (strchr($key,Aa)){
$tmp = imagecreatefrompng("images/bay.png");
array_push($colorpic,$tmp);
array_push($color,"Base Color is Bay Homozygous Extension and Heterozygous for the Wild-Type at Agouti");
}
elseif (strchr($key,AtAt)){
$tmp = imagecreatefrompng("images/bay.png");
array_push($colorpic,$tmp);
$tmp = imagecreatefrompng("images/seal.png");
array_push($colorpic,$tmp);
array_push($color,"Base Color is Seal/Brown Homozygous for Extension
Homozygous for Seal at Agouti");}
elseif (strchr($key,Ata)){
$tmp = imagecreatefrompng("images/bay.png");
array_push($colorpic,$tmp);
$tmp = imagecreatefrompng("images/seal.png");
array_push($colorpic,$tmp);
array_push($color,"Base Color is Seal/Brown Homozygous for
Extension Heterozygous for Seal at Agouti");}
elseif (strchr($key,AA)){
$tmp = imagecreatefrompng("images/bay.png");
array_push($colorpic,$tmp);
array_push($color,"Base Color is Bay Homozygous for
Extension and Wild-Type at Agouti");}
elseif (strchr($key,AtA)){
$tmp=imagecreatefrompng("images/bay.png");
array_push($colorpic,$tmp);
array_push($color,"Base Color is Bay Homozygous for Extension
Carries both Seal and Wild-Type Alleles at Agouti");}
else {
array_push($color,"Base Color is Black Homozygous for Extension and Homozygous for the recessive Alle at Agouti");
}
}
elseif (strchr($key,Ee)){
$dest = imagecreatefrompng("images/black.png");
imagealphablending($dest, true); // setting alpha blending on
imagesavealpha($dest, true); // save alphablending setting (important)
if (strchr($key,AAt)){
$tmp = imagecreatefrompng("images/bay.png");
array_push($colorpic,$tmp);
array_push($color,"Base Color is Bay Heterozygous for Extension and Carries both Seal and Wild-type Alleles at Agouti");}
elseif (strchr($key,Aa)){
$tmp = imagecreatefrompng("images/bay.png");
array_push($colorpic,$tmp);
array_push($color,"Base Color is Bay Heterozygous
Extension and Heterozygous for the Wild-Type at Agouti");
}
elseif (strchr($key,AtAt)){
$tmp = imagecreatefrompng("images/bay.png");
array_push($colorpic,$tmp);
$tmp = imagecreatefrompng("images/seal.png");
array_push($colorpic,$tmp);
array_push($color,"Base Color is Seal/Brown Heterozygous for
Extension Homozygous for Seal at Agouti");}
elseif (strchr($key,Ata)){
$tmp = imagecreatefrompng("images/bay.png");
array_push($colorpic,$tmp);
$tmp = imagecreatefrompng("images/seal.png");
array_push($colorpic,$tmp);
array_push($color,"Base Color is Seal/Brown Heterozygous for
Extension Heterozygous for Seal at Agouti");}
elseif (strchr($key,AA)){
$tmp = imagecreatefrompng("images/bay.png");
array_push($colorpic,$tmp);
array_push($color,"Base Color is Bay Heterozygous for
Extension and Wild-Type at Agouti");}
elseif (strchr($key,AtA)){
$tmp = imagecreatefrompng("images/bay.png");
array_push($colorpic,$tmp);
array_push($color,"Base Color is Bay Heterozygous for Extension
Carries both Seal and Wild-Type Alleles at Agouti");}
else {
array_push($color,"Base Color is Black Heterozygous for Extension and Homozygous for the recessive Alle at Agouti");
}
}
else {
array_push($color,"Base Color is Chestnut Homozygous for the recessive Alle at Extension");
$dest = imagecreatefrompng("images/red.png");
imagealphablending($dest, true); // setting alpha blending on
imagesavealpha($dest, true); // save alphablending setting (important)
if (strchr($key,AAt))
array_push($color," Carries both Seal and Wild-type Alleles at Agouti");
elseif (strchr($key,Aa)){
array_push($color," Heterozygous for the Wild-Type at Agouti");
}
elseif (strchr($key,AtAt))
array_push($color," Homozygous for Seal at Agouti");
elseif (strchr($key,Ata))
array_push($color," Heterozygous for Seal at Agouti");
elseif (strchr($key,AA))
array_push($color," Homozygous for Wild-Type at Agouti");
elseif (strchr($key,AtA))
array_push($color," Carries both Seal and Wild-Type Alleles at Agouti");
else {
array_push($color," Homozygous for the recessive Alle at Agouti");
}
}
if (strchr($key,"CC")){
array_push($color,"<br>Homozygous Cream");
$tmp = imagecreatefrompng("images/DD.png");
array_push($colorpic,$tmp);}
if (strchr($key,Ccr)){
array_push($color,"<br>Heterozygous Cream");
if (strchr($key,E)){
if (!strchr($key,aa)) {
$tmp = imagecreatefrompng("images/creamblack.png");
array_push($colorpic,$tmp);}}
else { $tmp = imagecreatefrompng("images/redcream.png");
array_push($colorpic,$tmp);}}
if (strpos($key,prlcr) || (strpos($key,crprl))){
array_push($color,"<br>Heterozygous Pearl");
}
if (strpos($key,Cprl)){
array_push($color,"<br>Heterozygous Cream and Pearl");
$tmp = imagecreatefrompng("images/DD.png");
array_push($colorpic,$tmp);}
if (strpos($key,prlprl)){
array_push($color, "<br>Homozygous Pearl");
$tmp = imagecreatefrompng("images/champagne.png");
array_push($colorpic,$tmp);}
if (strchr($key,DD)){
$tmp = imagecreatefrompng("images/dun.png");
array_push($colorpic,$tmp);
array_push($color,"<br>Homozygous Dun");}
if (strchr($key,D)){
array_push($color,"<br>Heterozygous Dun");
$tmp = imagecreatefrompng("images/dun.png");
array_push($colorpic,$tmp);}
if (strchr($key,CHCH)){
array_push($color,"<br>Homozygous Champagne");
$tmp = imagecreatefrompng("images/champagne.png");
array_push($colorpic,$tmp);}
if (strchr($key,Ch)){
array_push($color,"<br>Heterozygous Champagne");
$tmp = imagecreatefrompng("images/champagne.png");
array_push($colorpic,$tmp);}
if (strchr($key,ZZ)){
array_push($color,"<br>Homozygous Silver");
$tmp = imagecreatefrompng("images/silver.png");
array_push($colorpic,$tmp);}
if (strchr($key,Z)){
array_push($color,"<br>Heterozygous Silver");
$tmp = imagecreatefrompng("images/silver.png");
array_push($colorpic,$tmp);}
if (strchr($key,RR)){
array_push($color,"<br>Homozygous Roan");
$tmp = imagecreatefrompng("images/roan.png");
array_push($colorpic,$tmp);}
if (strchr($key,R)){
array_push($color,"<br>Heterozygous Roan");
$tmp = imagecreatefrompng("images/roan.png");
array_push($colorpic,$tmp);}
if (strchr($key,TT)){
array_push($color,"<br>Homozygous Tobiano");
$tmp = imagecreatefrompng("images/tobiano.png");
array_push($colorpic,$tmp);}
if (strchr($key,T)){
array_push($color,"<br>Heterozygous Tobiano");
$tmp = imagecreatefrompng("images/tobiano.png");
array_push($colorpic,$tmp);}
if (strchr($key,O)){
array_push($color,"<br>Heterozygous Frame");
$tmp = imagecreatefrompng("images/frame.png");
array_push($colorpic,$tmp);}
if (strchr($key,SBSB)){
array_push($color,"<br>Homozygous Sabino");
$tmp = imagecreatefrompng("images/DW.png");
array_push($colorpic,$tmp);}
if (strchr($key,SB)){
array_push($color,"<br>Heterozygous Sabino");
$tmp = imagecreatefrompng("images/sabino.png");
array_push($colorpic,$tmp);}
if (strchr($key,SPLSPL)){
array_push($color,"<br>Homozygous Splash");
$tmp = imagecreatefrompng("images/spsp.png");
array_push($colorpic,$tmp);}
if (strchr($key,SPL)){
array_push($color,"<br>Heterozygous Splash");
$tmp = imagecreatefrompng("images/sp.png");
array_push($colorpic,$tmp);}
if (strchr($key,LPLP)){
array_push($color,"<br>Homozygous Leopard Complex");
$tmp = imagecreatefrompng("images/LPLP.png");
array_push($colorpic,$tmp);}
if (strchr($key,LP)){
array_push($color,"<br>Heterozygous Leopard Complex");
$tmp = imagecreatefrompng("images/LP.png");
array_push($colorpic,$tmp);}
if (strchr($key,W)){
array_push($color,"<br>Heterozygous Dominant White");
$tmp = imagecreatefrompng("images/DW.png");
array_push($colorpic,$tmp);}
if (strchr($key,RBRB)) {
array_push($key,"<br>Homozygous Rabicano");
$tmp = imagecreatefrompng("images/rabicano.png");
array_push($colorpic,$tmp);}
if (strchr($key,RB)){
array_push($color,"<br>Heterozygous Rabicano");
$tmp = imagecreatefrompng("images/rabicano.png");
array_push($colorpic,$tmp);}
if (strchr($key,GG)){
array_push($color,"<br>Homozygous Gray");
$tmp = imagecreatefrompng("images/gray.png");
array_push($colorpic,$tmp);}
if (strchr($key,G)){
array_push($color,"<br>Heterozygous Gray");
$tmp = imagecreatefrompng("images/gray.png");
array_push($colorpic,$tmp);}
$colors=implode(" ",$color);
//layer the imges in the $colorpic array
foreach ($colorpic as $img){
imagealphablending($img, true); // setting alpha blending on
imagesavealpha($img, true); // save alphablending setting (important)
imagecopy($dest,$img,0,0,0,0,816,542);}
//added for testing take the spaces out of $key and save to a new variable
$name = str_replace (" ", "", $key);
//create hidden div
echo "<div id=\"uniquename$j\" style=\"display:none;float:right;position: relative; top: -250px; clear:both;width:407px;\"><p>";
//send layered img to file
imagepng($dest,"images/$name.png");
imagedestroy($dest);
//print layered img
print "<img src=\"images/$name.png\" width=\"407\" height=\"271\">";
echo "<br>$colors";
echo "</p></div>";
$j++;
}
echo "</div>";
I've tried substituting several different things for $key...$name$j actually works as does $j$name. img$name does not work nor does $name.img I'm completely dump struck as to why $name$j would work but not $name