IMHO the function()[] syntax should be allowed, but it isn't.

You could use list() or extract(), but then you'd wind up with a lot more date 
than you want. What I've been doing is creating a function, then calling when 
needed. For example:

function array_get_value($array, $index) {
        return $array[$index];
}

array_get_value(getdate($timestamp), 'year');

If you'd like to fill out a bug report (use 'feature request' for the type of 
bug), http://bugs.php.net/




On Friday 30 May 2003 06:52 pm, Dustin Mitchell wrote:
> I briefly tried searching the archives for this, but there aren't any handy
> keywords, so I didn't find anything.  Why can't I do this:
>
> $year = getdate($timestamp)['year'];
>
> (syntax error) while I can do this:
>
> $temp = getdate($timestamp);
> $year = $temp['year'];
>
> and is there a way to combine the above into one statement, however
> ungainly?
>
> This doesn't just happen with getdate -- it happens with any function
> returning an array.  I'm using PHP 4.1.2.
>
> Dustin

-- 

All religions are founded on the fear of the many and the cleverness of the 
few.

-Stendhal


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to