PHP syntax for dereferencing function result

后端 未结 22 881
不知归路
不知归路 2020-11-22 02:14

Background

In every other programming language I use on a regular basis, it is simple to operate on the return value of a function without declaring

22条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-22 02:38

    If you just want to return the first item in the array, use the current() function.

    return current($foo->getBarArray());
    

    http://php.net/manual/en/function.current.php

提交回复
热议问题