Wordpress PHP Array - Retrieve data from an array within another array -


i storing wordpress post data inside php array in order output page.

var1 outputs post permalink array inside ["post_link"]

var2 outputs array of further information image (title, url). how can change //var2 output ["url"] data within ["ad_img"]?

// var1 $posts_on_page[$current_page][get_the_id()]["post_link"] = get_permalink();  // var2 $adimgtest = get_field('ad_img');  $posts_on_page[$current_page][get_the_id()]["ad_img"] = $adimgtest;   var_dump($posts_on_page);   // var_dump response array(1) {   [0]=> array(1) {         [425951]=> array(11) {              ["post_link"] => string(50) "/welcome-message/"              ["ad_img"]=> array(18) {                ["title"]     => string(15) "img_placeholder"               ["url"        => string(77) "/img_placeholder-2.jpg"                   }     } } 

i thought following code work think going wrong somewhere:

$adimgtest = get_field('ad_img'); $posts_on_page[ $current_page ][ get_the_id() ]["ad_img"] = $adimgtest[0]->url; 

$adimgtest = get_field('ad_img'); $posts_on_page[ $current_page ][ get_the_id() ]["ad_img"] = $adimgtest[0]url; 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -