Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Help me grab a value from a multidimensional PHP array

I can't seem to get this value. here is the array:

[1596] => Array
(
    [entry_id] => 1596
    [title] => This is the article title
    [url_title] => url-title-here
    [status] => open
    [entry_date] => 1304544513
    [alt_title] => 
    [article_summary] => This is the article summary
    [article_intro] => This is the article intro
    [article_image] => 
    [article_body] => This is the article body
    [article_media_id] => 1
    [article_videos] => 
    [article_media] => Array
        (
            [0] => Array
                (
                    [row_id] => 3730
                    [row_order] => 0
                    [col_id_7] => image
                    [col_id_12] => right
                    [col_id_8] => 9781400068609.jpg
                    [col_id_9] => 
                    [col_id_10] => 
                    [col_id_54] => 
                )

        )

)

I am trying to build a URL using

'http://www.domain.com/uploads/media/'.$entry['entry_id']['article_media'][0]['col_id_8']

but it keeps giving me a '1' at the end of that image value. it should be 9781400068609.jpg, right? What do I have wrong?

like image 496
Chad Crowell Avatar asked Nov 14 '22 23:11

Chad Crowell


1 Answers

['entry_id'] is derailing your path. You'll want to refer to the top-level key by its number (probably in a variable) like this:

$entry_id = 1596;
$valueYouWant = $entry[$entry_id]['article_media'][0]['col_id_8'];
like image 64
Austin Avatar answered Dec 28 '22 13:12

Austin