I have the following PHP code:
<?php
$states = array("Alabama","Alaska","Arizona","Arkansas",
"California","Colorado","Connecticut","Delaware",
"Florida","Georgia","Hawaii","Idaho",
"Illinois","Indiana","Iowa","Kansas","Kentucky");
$stateAbbr = array("AL","AK","AZ","AR","CA","CO","CT","DE",
"FL","GA","HI","ID","IL","IN","IA","KS","KY");
?>
<!DOCTYPE html>
<html>
<body>
<h1>List of States</h1>
</body>
</html>
Now I need to add a PHP code to print the state and state abbreviation as a table by loop through all elements, using a for loop, and echo elements from both arrays at every index
foreachloop: php.net/manual/en/control-structures.foreach.php<?php $states = array("Alabama","Alaska","Arizona","Arkansas", "California","Colorado","Connecticut","Delaware", "Florida","Georgia","Hawaii","Idaho", "Illinois","Indiana","Iowa","Kansas","Kentucky"); $stateAbbr = array("AL","AK","AZ","AR","CA","CO","CT","DE", "FL","GA","HI","ID","IL","IN","IA","KS","KY"); ?> <!DOCTYPE html> <html> <body> <h1>List of States</h1> <?php foreach($states as $key => $value): echo $stateAbbr[$key]."=".$value."<br>"; endforeach; ?> </body> </html>