tags:

views:

19

answers:

1

I have the line

if( getdate($start_time)['hours'] == 0 ){

and I am getting

Parse error: syntax error, unexpected '['

But if I change the line to

$start_time_as_date = getdate($start_time);
if( $start_time_as_date['hours'] == 0 ){

I don't get an error. Do I always have to save an array to a variable to access its data? Or is there some way to make the first line work?

+1  A: 

Yes you do. PHP does not allow you to access an array return value in that way.

cletus
More discussion over at http://stackoverflow.com/questions/13109/php-access-array-value-on-the-fly
Jonathan Sampson