This is in Drupal but should be applicable for normal PHP.
field-event-address is an array that is under $entity_fetched
.
<?php if ($entity_fetched->field-event-address != "") echo $entity_fetched->field-event-address['und']['0']['value']; ?>
For some reason, when I do this, I get this error if I leave the ['und']['0']['value']
off:
Notice: Undefined property: stdClass::$field in eval() (line 7 of /opt/staging/contitemp/public_html/sites/all/modules/rules/modules/php.eval.inc(125) : eval()'d code).
Notice: Use of undefined constant event - assumed 'event' in eval() (line 7 of /opt/staging/contitemp/public_html/sites/all/modules/rules/modules/php.eval.inc(125) : eval()'d code).
Notice: Use of undefined constant address - assumed 'address' in eval() (line 7 of /opt/staging/contitemp/public_html/sites/all/modules/rules/modules/php.eval.inc(125) : eval()'d code).
And this error if I leave it on:
Parse error: syntax error, unexpected '[', expecting ',' or ';' in /opt/staging/contitemp/public_html/sites/all/modules/rules/modules/php.eval.inc(125) : eval()'d code on line 7
I am trying to create an if statement that checks to see if the array under the object is empty or not, and if it isn't, echos the array contents.
I'm really scratching my head with this one - I should be able to just check if an array is empty if it's under an object, correct?