note 48 modified in function.reset by felipe
| From: | felipe@php.net | Date: | Tue, 22 Jul 2008 18:46:04 +0000 |
| Subject: | note 48 modified in function.reset by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142517@lists.php.net to get a copy of this message | ||
When used on a scalar or unset value, reset() spews warning messages. This is often a problem when
accessing arrays generated from HTML form input data: these are scalar or unset if the user
didn't enter sufficient information.
You can silence these error messages by prefixing an @ (at sign) to reset(), but it is better style
to protect your reset() and the following array traversal with an if (isset()). Example code:
<?php
if (isset($form_array)) {
reset($form_array);
while (list($k, $v) = each($form_array) {
do_something($k, $v);
}
}
?>
--was--
When used on a scalar or unset value, reset() spews warning messages. This is often a problem when
accessing arrays generated from HTML form input data: these are scalar or unset if the user
didn't enter sufficient information.
You can silence these error messages by prefixing an @ (at sign) to reset(), but it is better style
to protect your reset() and the following array traversal with an if (isset()). Example code:
if (isset($form_array)) {
reset($form_array);
while (list($k, $v) = each($form_array) {
do_something($k, $v);
}
}
http://php.net/manual/en/function.reset.php