performance - PHP: Fastest way to handle undefined array key - Stack Overflow

PHOTO EMBED

Mon Aug 01 2022 15:18:35 GMT+0000 (Coordinated Universal Time)

Saved by @kalehm #php

    if (isset($lookup_table[$key])) {
        return $lookup_table[$key];
    } else {
        return;
    }

or 

return array_key_exists($key, $table) ? $table[$key] : null;

or 

return $table[$key] ?? null;
content_copyCOPY

https://stackoverflow.com/questions/16675753/php-fastest-way-to-handle-undefined-array-key