Skip to content

Instantly share code, notes, and snippets.

@451F
Created July 3, 2017 13:41
Show Gist options
  • Select an option

  • Save 451F/2c75727058a1deba77c548cd0cb30c02 to your computer and use it in GitHub Desktop.

Select an option

Save 451F/2c75727058a1deba77c548cd0cb30c02 to your computer and use it in GitHub Desktop.
<?php
$input_array = [
"55.10",
"55.01",
"50.01",
"55.00",
"50.00"
];
function clear_zeroes(array $input) {
$output = [];
foreach ($input as $key => $value) {
$output[] = preg_replace("/\.?0+$/", "", $value);
}
return $output;
}
var_dump(clear_zeroes($input_array));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment