-1

I have a multidimensional array that I am attempting to get a value of a key, so my code starts like this:

$doc = $data->field_field;
$print_r($doc);

which prints out this:

Array
(
[0] => Array
    (
        [rendered] => Array
            (
                [#markup] => link1 //what I want to grab
                [#access] => 1
            )

        [raw] => Array
            (
                [fid] => **
                [uid] => **
                [filename] => ****.docx
                [uri] =>****.docx
                [filemime] => 
                [filesize] => 
                [status] => 1
                [timestamp] => 
                [type] => default
                [uuid] => 
                [rdf_mapping] => Array
                    (
                    )

                [display] => 1
                [description] => 
            )

    )

)

I am trying to grab the value of [#markup] which is a link.

Ren44
  • 107
  • 1
  • 1
  • 11

1 Answers1

1

Use this:

$doc[0]["rendered"]["#markup"]
Nathaniel Ford
  • 20,545
  • 20
  • 91
  • 102
  • Thanks! that worked for me, forgot the quotes *facepalm* – Ren44 Mar 10 '16 at 20:53
  • I am not sure if I should edit my question but what if I have two values in my array so $doc[0]... doc[1].. etc. I wonder how my foreach loop would look like to capture? Any ideas? – Ren44 Mar 10 '16 at 21:00
  • Best to ask a separate question and follow the [Minimal, Complete, and Verifiable example guidelines](http://stackoverflow.com/help/mcve). – Nathaniel Ford Mar 10 '16 at 21:01