Jordash
Jordash

Reputation: 3093

Accessing a Value in an Array

I have this massive array that looks like this somewhat:

[field_sidebarhtml] => Array
(
    [und] => Array
        (
            [0] => Array
                (   [value] => Custom Sidebar Content
                    [format] => filtered_html
                    [safe_value] => 
Custom Sidebar Content
                )
        )
)

==> Actually, Here is the entire Array http://psdesignzone.com/fullarray.txt

I need to access the 'safe_value' in the variable array which is named '$page' how would I do that?

Upvotes: 0

Views: 196

Answers (2)

Magicianeer
Magicianeer

Reputation: 2180

based on fullarray.txt

$tmp_obj = $page['content']['system_main']['nodes'][7]['body']['#object'];
$val = $tmp_obj->body['field_sidebarhtml']['und'][0]['safe_value'];

Note that '#object' is a stdClass instance instead of an array is not clear from your question text, only in fullarray.txt.

(edited to find the first instance of safe_value with "Custom Sidebar Content") A second instance occurs at

$tmp_obj = $page['content']['system_main']['nodes'][7]['field_sidebarhtml']['#node];
$val = $tmp_obj->body['field_sidebarhtml']['und'][0]['safe_value'];

There are probably more.

Upvotes: 2

CSᵠ
CSᵠ

Reputation: 10169

print $bigarray['field_sidebarhtml']['und'][0]['safe_value']

that will output:

Custom Sidebar Content

Upvotes: 1

Related Questions