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

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

    I am guessing that this is a built-in or library function, since it sounds like you cannot edit it directly. I recommend creating a wrapper function to give you the output you need:

    function functionThatReturnsOneElement( $arg )
    {
        $result = functionThatReturnsAnArray( $arg );
        return $result[0];
    }
    $firstElement = functionThatReturnsOneElement();
    

提交回复
热议问题