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

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

    list() is useful here. With any but the first array element, you'll need to pad it with useless variables. For example:

    list( $firstElement ) = functionThatReturnsAnArray();
    list( $firstElement , $secondElement ) = functionThatReturnsAnArray();
    

    And so on.

提交回复
热议问题