Array returning error "Can’t use Function Return value in write context in"

Asked

Viewed 271 times

0

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

Fatal error: Can’t 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;
}

...

1 answer

0

Motive

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

$array($x) = $genero01;

$array($x) = $genero02;

Correcting

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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.