Michael B Allen wrote:
Is there any preference for:
$val = isset($arr['key']) ? $arr['key'] : null;
vs:
$val = @$arr['key'];
?
Oftentimes I like to check for a key value, and then supply a default if
it is not there. It can be useful to make up a routine that does this
for you all in one step:
$rowsPerPage = arraySafe($options,'rowsperpage',25);
$orderLines = arraySafe($orders,'lines',array());
The function is:
function arraySafe($array,$key,$default='') {
if(isset($array[$key]))
return $array[$key];
else
return $default;
}
--
Kenneth Downs
Secure Data Software, Inc.
www.secdat.com www.andromeda-project.org
631-689-7200 Fax: 631-689-0527
cell: 631-379-0010
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php