• I have a user meta field call our_children. When I look at the output of the field I see:

    [our_children] => Array ( [0] => s:59:”a:1:{i:0;a:2:{s:4:”Name”;s:6:”Elisha”;s:3:”Age”;s:2:”13″;}}”; )

    I made it an array so that people can add more children.

    I can;t seem to figure out how to display the information in the array.

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • I think you can get what you want by ‘unserializing’ the first element of the array:

    $string = unserialize($our_children[0]);
    $array = unserialize($string);
    $data = $array[0];
    echo "Name: $data->Name  Age: $data->Age";

    (There may be a more elegant way to do this.)

    Thread Starter Jonah Brown

    (@fishbaitbytes)

    Oh thanks,

    I found out about the unserialize part. Been plugging away at it this morning.

    $children = unserialize($our_children[0]);

    Didn’t know about the part in the code you wrote where I can array the unserialize string.

    So I messed with code till I came up with this:

    foreach ( $children as $child ) {
    		     	echo '<tr><td>'. $child[Name].'</td><td>'. $child[Age] .'</td><td colspan="3">'. $child[Sex] .'</td></tr>';
    		     	}

    But thanks for your tidbits.

    Thread Starter Jonah Brown

    (@fishbaitbytes)

    Do you know how I can split this?

    I home educate my children or someone else’s (registered or enrolled),I run a business that benefits home education families and I would like to list it in the Member Directory and Service Guide

    the entry in the user meta is

    [who_i_am] => Array ( [0] => I home educate my children or someone else’s (registered or enrolled),I run a business that benefits home education families and I would like to list it in the Member Directory and Service Guide )

    tried this but it is not working

    $i_am = explode(",", $who_i_am);
    		     	?>
    		     	   	<li><?php echo $i_am; ?></li>
    		     	<?php

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display User Meta’ is closed to new replies.