PHP只显示数据行中的一段数据

What I have done so far is to write a function which I call on another page:

<div style="<?php echo groupColor($_SESSION['username']); ?>"><?php echo $_SESSION['username']; ?></div>

What it does it that retrieves the username_css style from the xf_user_group and that way I can color the user's username by the color they have on a xenforo forum board (all username_css contain color: #somecolorcode;)

function groupColor($username) {

    global $xenforo;

    $xf_getuser = $xenforo->query("SELECT * FROM xf_user WHERE username = '".$username."'");

    if($xf_getuser->num_rows >= 1) {

        $fetch_xf_getuser = $xf_getuser->fetch_array();
        $fetch_xf_getuser_group = $fetch_xf_getuser["display_style_group_id"];

        $xf_getgroupstyle = $xenforo->query("SELECT * FROM xf_user_group WHERE user_group_id = '".$fetch_xf_getuser_group."'");

        if($xf_getgroupstyle->num_rows >= 1) {

            $fetch_xf_getgroupstyle = $xf_getgroupstyle->fetch_array();
            $result_forum_css = $fetch_xf_getgroupstyle["username_css"];

            return $result_forum_css;

        } else {

            die(mysqli_error($xenforo));

        }

    } else {

        die(mysqli_error($xenforo));

    }

}

What I am looking to do now, is to only extract color: #somecolorcode; from username_css so I can use it to color a background instead, like this: background-color: #somecolorcode;

Any idea how I should continue? All help is appreciated, and sorry for the bad title, I'm not of sure what the method is called.

EDIT 1: The username_css row does not only contain color: #colorcode; but also stuff like: font-weight: bold; font-style: italic; color: red;

You can try getting all data after color: using strpos and substr:

$css = "color:#000000;";
$color = substr($css, strpos($css, ':')+1, 7);

// Color is #000000
echo $color;

Instead of below line.

 return $result_forum_css;

replace it with this.

 $total_prop = count($result_forum_css);
 $explode_result = explode(";",$result_forum_css);
 return $explode_result[$total_prop-2];

Here, based on your comment we will count the total result and the last result will always be blank so, we fetch second last element and so that we negate total count with 2.