note 86852 deleted from control-structures.foreach by googleguy
| From: | googleguy@php.net | Date: | Wed, 14 Nov 2012 22:29:40 +0000 |
| Subject: | note 86852 deleted from control-structures.foreach by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191967@lists.php.net to get a copy of this message | ||
Note Submitter: zodiac2800 at msn dot com
----
Here is a way to declare global variable variables using a function.
This particular example handles an array that contains names of $_POST items. This is to avoid the
notices that php gives when checking an unused $_POST.
<?php
function check ($inputs) {
foreach ($inputs as $input) {
global $$input;
$$input = isset($_POST[$input]) ? $_POST[$input] : "";
}
}
?>