Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Sc0tt on
Thank you for any help with this.
I'm using <?php print_r($node); ?>
to see the following array output.
[field_headline_options] => Array
(
[0] => Array
(
[value] => headline-color-black
[safe] => headline-color-black
[view] => Color: Black
)
[1] => Array
(
[value] => headline-size-medium
[safe] => headline-size-medium
[view] => Size: Medium
)
)
I'm trying to access the [value] element of the array using the following:
<?php foreach ($field_headline_options as $value) {
print $value; } ?>
I'm only getting the output "Array Array" instead of the desired "headline-color-black headline-size-medium". Can any php guru explain how to access a particular element (in this case 'value') from an array using a foreach command?
Thank you very much,
Scott
Ps. Using D6 with Zen theme.
Comments
You would want to print
You would want to print $value['value']
use print $value['value'] to
use
to get output "headline-color-black headline-size-medium".
Then try the following:
Worked Perfect!
Thank you nevets and suvasish mondal
Scott