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?

mcstrother
  • 5,227
  • 5
  • 20
  • 18

1 Answers1

1

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

cletus
  • 578,732
  • 155
  • 890
  • 933
  • 1
    More discussion over at http://stackoverflow.com/questions/13109/php-access-array-value-on-the-fly – Sampson Dec 19 '09 at 04:44