In PHP, I have an array of variables that are ALL strings. Some of the values stored are numeric strings with commas.
What I need:
A way to trim the comma
It sounds like the ideal solution for what you're looking for is filter_var()
:
$a = filter_var($a, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND);
(Note that it's using FILTER_VALIDATE_FLOAT instead of FILTER_VALIDATE_INT because that one doesn't currently have a FILTER_FLAG_ALLOW_THOUSAND option).