Array returning error "Can not use function return value in write context in"

0

I am creating a array but it is returning me the error:

  

Fatal error: Can not use function return value in write context in C: \ xampp \ htdocs \ cadastro_insert.php on line 54:

Where am I going wrong?

$array = array(1, 2, 3, 4, 5, 6); --> tambem tentei:  $genero = array(6);
$x = 0;

if ($genero01 != "") {
$x++;
$array($x) = $genero01;
}

if ($genero02 != "") {
$x++;
$array($x) = $genero02;
}

...

    
asked by anonymous 28.01.2018 / 00:18

1 answer

0

Reason

As already mentioned, the error was when calling the array, where you are using parentheses instead of brackets :

$array($x) = $genero01;

$array($x) = $genero02;

Correcting

if ($genero01 != "") {
  $x++;
  $array[$x] = $genero01;
}

if ($genero02 != "") {
  $x++;
  $array[$x] = $genero02;
}
    
28.01.2018 / 02:28