mercredi 4 mars 2015

Why error with with if (($x = $y)['abc'] == 'test')?

I have the following code:



if (mysqli_num_rows($result) && ($value = mysqli_fetch_array($result))['id'] != $id)


And I get the following mistake:



$Parse error: syntax error, unexpected '[' in [...]



But I don't get the point!



if (mysqli_num_rows($result) && mysqli_fetch_array($result)['id'] != $id)


this works fine, but I want to save the result of mysqli_fetch_array. And I thought that would easily possible without a second If-Clause.


Aucun commentaire:

Enregistrer un commentaire