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

前端 未结 17 1120
抹茶落季
抹茶落季 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:59

    I think any of the above would require a comment to explain what you're doing, thus becoming two lines. I find it simpler to do:

    $element = functionThatReturnsArray();
    $element = $element[0];
    

    This way, you're not using an extra variable and it's obvious what you're doing.

提交回复
热议问题