I'm trying to manipulate a text string based on values assigned to a user.
The FULL text string is 'Lists, Items, Cases, Identity and Location' and this is only shown in full against ADMIN.
Each user on the system has access rights. Each right determines what they can and can't do.
So access right a1 = 'Lists', b1 = 'Items' etc...
When the user logs in the page shows what they have access to.
eg:
Welcome $user
You have access to $foo
for the admin user.. this would look like:
Welcome Admin
You have access to Lists, Items, Cases, Identity and Location
So now I'm trying to do the following :
if ($user == 'admin') $foo = 'Lists, Items, Cases, Identity and Location'; // full access
But I need to be able to change the value for each user.
$foo ='';
if (strpos($access,'a1') !== false) $foo .= 'Lists ';
if (strpos($access,'b1') !== false) $foo .= 'Items ';
if (strpos($access,'c1') !== false) $foo .= 'Cases ';
if (strpos($access,'d1') !== false) $foo .= 'Identity ';
if (strpos($access,'e1') !== false) $foo .= 'Location ';
The issue I have with this is the punctuation is messed up. The user Miz has access to a1,b1,c1
When she logs in she gets:
Welcome Miz
You have access to Lists Items Cases
What I'd like it to say is:
Welcome Miz
You have access to Lists, Items and Cases
Can anyone advise the best way to achieve this
Thanks