if(isset($arr['d'])) $something = $arr['d'];
unset($arr['d']);
Well... If arr['d']
is not set, then you don't need to unset it. So this will save an unnecessary call sometimes:
if(isset($arr['d']))
{
$something = $arr['d'];
unset($arr['d']);
}
If you don't care for $something
, then you can just do
unset($arr['d']);
Which is then one line. You could also write
if (isset($arr['d']) && ($something = $arr['d']) !== null) unset($ar['d']);
That is one line as well, but will fail to do what you like if $something
is null
. And from the point of readability it's questionable whether this is an improvement.