在MySQL数据库中从数组中分配变量

I'm fetching table data from a mysql database using PHP. One of the fields in the database (memberProperties) is an array of data that gets outputted like this:

{
    "title":"-",
    "first_name":"Joe",
    "last_name":"Bloggs",
    "role":"Senior Scientist",
    "phone":"61240 652135",
    "start_date":"2016-05-20",
    "leave_date":"2016-05-20",
    "location":null,
    "team":"Engineering",
    "platform":"Rockets",   
    "username":"joe.bloggs",
    "from_ad":"true",
    "full_name":"Joe Bloggs",
    "display_name":"Joe Bloggs",
    "mobile":null,
    "company":"ACM WIDGETS"
}

How do I cycle through each value and assign a variable that can be reused in the page? I have tried to do the following according to a w3schools PHP tutorial... but it doesn't seems to output the values separately.

$my_array = array($row["memberProperties"]);

      list($title, $first_name, $last_name, $role, $phone, $start_date, $leave_date, $location, $team, $platform, $username, $from_ad, $full_name, $display_name, $mobile, $company) = $my_array;
      echo "$title, $first_name, $last_name, $role, $phone, $start_date, $leave_date, $location, $team, $platform, $username, $from_ad, $full_name, $display_name, $mobile, $company";

As poeple have suggested using json_decode will convert your string to php object

and in your code you can use that like below

$memberProperty = json_decode($row["memberProperties"]);

print_r($memberProperty->first_name)

the output will be

Joe

That's a JSON string. You need to decode it before you can use it as an array. Give this a try:

$array = json_decode($row["memberProperties"]);
echo '<pre>'; var_dump($array); echo '</pre>';

Use this function :

   $string_data = json_decode($array);

The value that you have shown within your question is not an instead instead its JSON string you can use json_decode along with foreach like as

$json = '{"title":"-","first_name":"Joe","last_name":"Bloggs","role":"Senior Scientist","phone":"61240 652135","start_date":"2016-05-20","leave_date":"2016-05-20","location":null,"team":"Engineering","platform":"Rockets","username":"joe.bloggs","from_ad":"true","full_name":"Joe Bloggs","display_name":"Joe Bloggs","mobile":null,"company":"ACM WIDGETS"}';

$json_array = json_decode($json,true);
foreach($json_array as $k => $v){
    ${$k} = $v;
}
$arr = get_defined_vars();
print_r($arr);

Here get_defined_vars() will show you all the variables within your file

Demo