PHP: Can I reference a single member of an array that is returned by a function?

前端 未结 17 1115
抹茶落季
抹茶落季 2020-12-19 00:21

any idea how if the following is possible in PHP as a single line ?:

... It doesn

17条回答
  •  情书的邮戳
    2020-12-19 00:39

    Well, I have found a couple of ways to get what you want without calling another function.

    $firstElement = ($t = functionThatReturnsAnArray()) ? $t[0] : false;
    

    and for strings you could use

    $string = (($t = functionThatReturnsAnArray())==0) . $t[0];
    

    .. Interesting problem

    Draco

提交回复
热议问题