I want to display partial values of JSON Encode values. Following is the code.

<?php global $wpdb; $project_member_details = $wpdb->get_var( $wpdb->prepare( "SELECT project_members FROM wpxa_project_members WHERE project_id = 603" ) ); echo $project_member_details; ?>

I get following result...

{"member_image":["21604_1530889966_1408904487.png","21604_1530889966_1590217155.jpg","21604_1530889966_1179667677.png"],"member_name":["Test","Best","Guest"],"member_role":["Test1","Best1","Guest1"],"member_email":["[email protected]","[email protected]","[email protected]"],"member_facebook_id":["Test3","Best3","Guest3"]}

But I want only this... How to do...


Plz help...

1 Answer 1


Use json_decode:

global $wpdb;
$project_member_details = $wpdb->get_var( $wpdb->prepare( "SELECT project_members FROM wpxa_orocox_project_members WHERE project_id = 603" ) );
$project_member_details = json_decode( $project_member_details, true );
print_r( $project_member_details['member_image'] );

If you still want the output to be JSON encoded at the end of it, you could then do something like:

$member_images = $project_member_details['member_image'];
echo wp_json_encode( [ 'member_image' => $member_images ] );

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.