perl style in php ?

From: crub (crub_at_volcanomail.com)
Date: 10/31/04


Date: 31 Oct 2004 07:59:49 -0800

Often I just want to be able to get at a single element from a
function that returns an array. For example, if I just want the
current year I need to write:

    $today = getdate();
    $year = $today['year'];

Call me lazy but this is two steps to return a single value.
In perl I can nest these two step together into something like:

     $year = ( $getdate() )['year'];

I've tried to get several variations of this to work in php but I
don't seem to be having any luck.

Is this style possible in php?

Thanks,
crub



Relevant Pages

  • Re: perl style in php ?
    ... > Often I just want to be able to get at a single element from a ... > function that returns an array. ... > I've tried to get several variations of this to work in php but I ... What I often do in this situation is use extract(). ...
    (comp.lang.php)
  • Re: Problem with array ref (I think!)
    ... More importantly my formula reversed the ranges column A for L so it should ... Microsoft Excel MVP ... *always* returns an array even if the reference is to a single element. ... ROW is taking the single cell ref and making it an array. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Problem with array ref (I think!)
    ... Microsoft Excel MVP ... *always* returns an array even if the reference is to a single element. ... ROW is taking the single cell ref and making it an array. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Problem with array ref (I think!)
    ... *always* returns an array even if the reference is to a single element. ... ROW is taking the single cell ref and making it an array. ... of the bottom of the table is in cell B9. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Problem with array ref (I think!)
    ... Microsoft Excel MVP ... *always* returns an array even if the reference is to a single element. ... ROW is taking the single cell ref and making it an array. ...
    (microsoft.public.excel.worksheet.functions)