Add verification that var is not array or object for running str_replace().