the convention around here is "New question, new thread".
That allows for short, direct answer to short, direct questions instead of long, rambling threads where all the "Goodness" gets lost.
Some comments on the above:
the use of "global" breaks encapsulation, requiring the environment "outside" the function to provide the variable.
It is better to pass the data as an argument to the function.
What value does admin['gender'] have?
Any value passed that resolves to true will cause the ternary operator to return "Mr" and everything else will return "Mrs".
The code makes no attempt to ensure that the array indexes used actually exist; this may or may not be an issue.
What if the individual is female and not married?
They might object to being called "Mrs".
What if the individual is not gender-identifying?
They would object most strongly to be referred to by either of the terms used here.
Marital status and/or gender are both Personal Data and should be stored in the User's "record" (whatever form that takes) so that it can be managed by/on behalf of the User and changed over time.
Regards,
Phill W.