note 73165 added to language.types.array
| From: | (www.andrei.md) | Date: | Sun, 11 Feb 2007 22:55:52 +0000 |
| Subject: | note 73165 added to language.types.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-123261@lists.php.net to get a copy of this message | ||
A simple way to suppress 'undefined index' errors is the same as for function calls -
prefix array access with the @ sign.
<?php
$array = Array();
$b = @$array['b'];
if (is_null($b)) {
echo "b is null";
}
?>
Will output 'b is null' without an error.
Handy for deep/dynamic arrays
----
Server IP: 203.220.0.234
Probable Submitter: 203.206.128.174
----
Manual Page -- http://www.php.net/manual/en/language.types.array.php
Edit -- https://master.php.net/note/edit/73165
Del: integrated -- https://master.php.net/note/delete/73165/integrated
Del: useless -- https://master.php.net/note/delete/73165/useless
Del: bad code -- https://master.php.net/note/delete/73165/bad+code
Del: spam -- https://master.php.net/note/delete/73165/spam
Del: non-english -- https://master.php.net/note/delete/73165/non-english
Del: in docs -- https://master.php.net/note/delete/73165/in+docs
Del: other reasons-- https://master.php.net/note/delete/73165
Reject -- https://master.php.net/note/reject/73165
Search -- https://master.php.net/manage/user-notes.php