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

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

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

... It doesn

17条回答
  •  -上瘾入骨i
    2020-12-19 00:56

    You can use array_slice(), like so:

    $elementX = array_slice(functionThatReturnsAnArray(), $x, 1);
    

    Also noticed that end() is not mentioned. It returns the last element of an array.

提交回复
热议问题