President [NAME] served from [TERM]

\n"; // Loops through the $Presidents array. $Sequence is the index of the array variable (0,1,2,3,4,5). $Name stores // the name of the each president. foreach ($Presidents as $Sequence => $Name) { //Replaces the '[NAME]' string in the $OutputTemplate string with the $Name variable contents. $TempString = str_replace("[NAME]", $Name, $OutputTemplate); $OutputString = str_replace("[TERM]", $YearsInOffice[$Sequence], $TempString); echo $OutputString; } ?>