3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $node = (object) array( 'nid' => 5, ); $data = array( 'subject' => 'subject', 'content' => 'Some string', ); // For some cases rewrite the content if ($node->nid > 5) { $content = $data['content'] . '<ul><li>List</li><li>with</li><li>some</li><li>items</li>'; $data['content'] = array( 'markup' => $content, '#attached' => array( 'js' => array( 'some_file.js', ), ), ); } if (!array_key_exists('markup', $data['content'])) { $data['content'] = array( 'markup' => $data['content'], ); } print_r($data); // Really? var_dump($data['content']['markup']);
based on chiVg
Output for 5.3.0 - 7.2.0
Warning: array_key_exists() expects parameter 2 to be array, string given in /in/S8Av5 on line 26 Array ( [subject] => subject [content] => Array ( [markup] => Some string ) ) string(11) "Some string"
Output for 4.3.2 - 5.2.17
Warning: array_key_exists(): The second argument should be either an array or an object in /in/S8Av5 on line 26 Array ( [subject] => subject [content] => Array ( [markup] => Some string ) ) string(11) "Some string"
Output for 4.3.0 - 4.3.1
Warning: array_key_exists() [http://www.php.net/function.array-key-exists]: The second argument should be either an array or an object in /in/S8Av5 on line 26 Array ( [subject] => subject [content] => Array ( [markup] => Some string ) ) string(11) "Some string"