平成30/ 2018-10-24 08:55
php/ 可変関数

foreach(array(
"skill_li"     => "skillLi",
"work_env_li"  => "workEnvLi",
) as $key      => $val){
    $upper = strtoupper($key);
    $fn = $val;
    if(
    isset($_SESSION["search"][$key])
    ){
        ${$upper} = $_SESSION["search"][$key];
    } else{
        ${$upper} = $fn();
        $_SESSION[$key] = ${$upper};
    }
}

( Thanks. )
可変関数
http://php.net/manual/ja/functions.variable-functions.php