Create variables with the values where you have conditionals, then just put the variables in the arrays.
Then put the array variables in the string replace.
Also, those conditionals where the else = "" are not necessary. Just put the values in. If it's not there, there is nothing to replace and it will move on.
So for example.
PHP Code:
($entry['security'] != "noone") ? "'{LOCKEDICON}'," : "")
Should just be
PHP Code:
"'{LOCKEDICON}',"