haku Posted April 3, 2009 Share Posted April 3, 2009 Look at this code: <?php $node = $form_state['node'] + (array)$node; } ?> I'm curious about it, as I have never seen code like this. First, how does the plus sign work in PHP? And what is (array)$node? This is new to me as well. Can anyone enlighten me? Link to comment https://forums.phpfreaks.com/topic/152347-whats-this/ Share on other sites More sharing options...
Mchl Posted April 3, 2009 Share Posted April 3, 2009 (array)$node cast $node variable to an array (basically makes sure it's an array) http://www.php.net/language.types.type-juggling How is it supposed to work with + however? Strange... Link to comment https://forums.phpfreaks.com/topic/152347-whats-this/#findComment-800100 Share on other sites More sharing options...
PFMaBiSmAd Posted April 3, 2009 Share Posted April 3, 2009 Presumably $form_state['node'] is an array, in which case - $a + $b Union of $a and $b. ... The + operator appends elements of remaining keys from the right handed array to the left handed, whereas duplicated keys are NOT overwritten. Link to comment https://forums.phpfreaks.com/topic/152347-whats-this/#findComment-800225 Share on other sites More sharing options...
haku Posted April 6, 2009 Author Share Posted April 6, 2009 Thanks guys, that answers my questions, and I see how it all works now. Link to comment https://forums.phpfreaks.com/topic/152347-whats-this/#findComment-801946 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.