I am creating a custom word press theme and i am little stuck in one situation, what i want is to echo the specific values of an array in the form of bordered tables. For example i want to display | location | qualification | date |

here below is my code

 <td class="row-2 row-email"><?php  $release_edu_qual = get_post_meta( get_the_ID(), '_candidate_education', true );

and this is the output of the above code:

Array ( [0] => Array ( [location] => Stanford University [qualification] => School of Arts & Sciences [date] => 2012-2015 [notes] => Maximus faucibus non non nibh. Cras luctus velit et ante vehicula, sit amet commodo magna eleifend. Fusce congue ante id urna porttitor luctus. ) [1] => Array ( [location] => University of Pennsylvania [qualification] => School of Design [date] => 2010-2012 [notes] => Phasellus vestibulum metus orci, ut facilisis dolor interdum eget. Pellentesque magna sem, hendrerit nec elit sit amet, ornare efficitur est. ) [2] => Array ( [location] => Massachusetts Institute of Technology [qualification] => [date] => 2006-2010 [notes] => Suspendisse lorem lorem, aliquet at lectus quis, porttitor porta sapien. Etiam ut turpis tempor, vulputate risus at, elementum dui. Etiam faucibus. ) )

  • $release1=$release_edu_qual[0]; print_r($release1); see the result Sep 2, 2020 at 11:21

2 Answers 2


The previous answer is wrong, to access the array elements, you need to get it by the key:

$location = $release_edu_qual[0]["location"];

In the above code, we're getting the location of the array that's first (zero based) in the initial array.

So to list all the array data you want from that initial array you could use something like:

        foreach( $release_edu_qual as $item ){
            echo '<tr>';
            echo    '<td>' . $item["location"]      . '</td>';
            echo    '<td>' . $item["qualification"] . '</td>';
            echo    '<td>' . $item["date"]          . '</td>';
            echo '</tr>';

To get a specific item in the object when already inside a specific array.

$location = $release_edu_qual->location;

To get all of a certain value use a foreach loop like this.

foreach ($release_edu_qual as $i) {
    $this_location = $i->location;
    print $this_location;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.