function username($user_level,$username) {
$staff_colours = array(
0 => '#000',
1 => '#fff',
2 => '#CC0',
3 => '#FFC',
5 => '#006'
);
$return_data = (array_key_exists($user_level, $staff_colours)) ? '<span style="color: '.$staff_colours[$user_level].';">'.$username.'</span>' : $username ;
return $return_data;
}
echo username($ir['user_level'],$ir['username']);
Quoted from (Internal Link)
Next time use the Search Function
Also just incase basically that code would go below your fetch row of $ir and then simple put
$ir['username'] = username($ir['level'],$ir['username']);
(not the best idea though when you call some queries like WHERE username = "'.$ir['username'].'")