Only variables should be passed by reference in php

1.4k views Asked by At

I have the following code :

    $_SESSION['aParties'] = time();
    $aParties[] = $_SESSION['aParties'];
    error_log(print_r($aParties,true), 3, "/var/tmp/error.log");
    $first = reset(ksort($aParties));

The array aParties is like this :

Array
(
  [0] => 1433841062
)

But I get the error :

'Only variables should be passed by reference in the method ksort' 

Help me please! Thx in advance

1

There are 1 answers

0
Narendrasingh Sisodia On

You need to do it as

ksort($aParties);
$first = reset($aParties);

Note: There is no reference sign on a function call - only on function definitions. Function definitions alone are enough to correctly pass the argument by reference.

Check Docs