php - Using arrays by reference -


why following code "crashing" in php?

$normal_array       = array(); $array_of_arrayrefs = array( &$normal_array );  end( $array_of_arrayrefs )["one"] = 1; // choking on 1 

the expected result final code line appends $normal_array key one having value 1 there no output ever, not prints preceeding code. in real context of scenario use end() function append last array reference.

this doesn't crash, contains syntax error:

end( $array_of_arrayrefs )["one"] = 1; 

unfortunately, cannot treat function return values arrays in php. have assign value explicitly. unfortunately, doesn't work here because end makes copy of returned value.


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -