title: Call function in array (PHP)
body: <p>In the building process of an array I'm trying to call a function, <em>checkIfNodeExists()</em>. PHP executes this function and gives me the expected result but he still gives me a "Notice", and I don't want any kind of errors in my code.</p>
  
  <pre><code>function checkIfNodeExists($input) {
     if (isset($input)) {
        return (string) $input;
     } else {
        return 'null';
     }
  }
  
  $array['sections'][] = array (
     'ident'       =&gt;  $section-&gt;attributes()-&gt;ident,
     'title'       =&gt;  $section-&gt;attributes()-&gt;title,
     'objective'   =&gt;  checkIfNodeExists($section-&gt;objectives-&gt;material-&gt;mattext)
  );
  </code></pre>
  
  <p>Notice: Trying to get property of non-object in /var/www/OLAT_Connection/QTI-XML-Parser.php on line xx</p>
  
  <p>Now, if I check if "objective" exists OUTSIDE the array, PHP doesn't give me a notice. But this results in more lines of code because I have to work with an extra variabele and more IF-structures and so on...</p>
  
  <p>Is there any other possibility without adding too much lines of extra code?</p>