How would I be able to make a table from php using html with a foreach loop? My goal is to have a table with href tags for each of the sites. It’s just that I’m a newbie to php
JavaScript
x
<?php
$baseConf = ['site' => [abc.com],[abc.org]];
?>
<!DOCTYPE html>
<html>
<head>
<title>Default Page</title>
</head>
<body>
<table>
<!--<a href="<?php //$site; ?>"><?php //$site; ?></a>-->
<?php
foreach($site as $value ) {
printf $value;
}
?>
</table>
</body>
</html>
Advertisement
Answer
I have fixed my code a bit and this is what worked out:
JavaScript
$baseConf = array(
'site' => array("abc.com","abc.org"),
);
?>
<!DOCTYPE html>
<html>
<head>
<title>Default Page</title>
</head>
<body>
<!--<a href="<?php //$site; ?>"><?php //$site; ?></a>-->
<?php
foreach ($baseConf as $value) {
//echo "$valuen";
print_r($value);
}
?>
</body>
</html>