foreach($_POST as $key => $value) {
$Body .= "<p>$key: $value</p>";
}
ASKER
ASKER
<?php // demo/temp_johnmac328.php
/**
* http://www.experts-exchange.com/questions/28937729/PHP-foreach-syntax.html
*/
error_reporting(E_ALL);
// IF THE FORM HAS BEEN POSTED
if (!empty($_POST))
{
// SHOW THE CONTENTS OF THE REQUEST
var_dump($_POST);
// ITERATE OVER THE CONTENTS OF THE REQUEST
$thing = NULL;
foreach ($_POST as $key => $val)
{
$thing .= "<p>$key: $val</p>";
}
echo $thing;
}
// CREATE THE FORM USING HEREDOC NOTATION
$form = <<<EOD
<form method="post">
Name: <input name="yourname" /><br>
Email: <input name="youremail" /><br>
Phone: <input name="yourphone" /><br>
<input type="submit" value="Go!" />
</form>
EOD;
echo $form;
ASKER
foreach($_POST as $key => $value) {
$Body .= "<p>$key: $value</p>";
echo $key['name'], " ", $$key['company_name'], " ", $$key['email'];
}
ASKER
PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.
TRUSTED BY