PHP: Fastest way to handle undefined array key

后端 未结 8 1672
梦如初夏
梦如初夏 2020-12-08 07:13

in a very tight loop I need to access tenthousands of values in an array containing millions of elements. The key can be undefinied: In that case it shall be legal to return

8条回答
  •  北荒
    北荒 (楼主)
    2020-12-08 07:47

    This Work for me

    {{ isset($array['key']) ? $array['key']: 'Default' }} 
    

    but this is fast

    {{ $array['key'] or 'Default' }}
    

提交回复
热议问题