Menu
I’m building an array which is later JSON encoded.
As I build the array I’m adding numbers to items in the array. These are numbers and works fine.
`‘MyPosts’ => $row[‘pstcnt’],
However, I wanted to number format it or replace 0 with a dash. So I created a function
“`
function dashOnZero($value) {
if($value == 0){
return “-“;
exit();
} else {
return number_format($value);
exit();
}
}
Now when I make my array
`‘MyPosts’ => dashOnZero($row[‘pstcnt’]),
But I don’t get any errors, dashes or formatted numbers (I get zeros and 3233 not 3,233)