Yii v2 snippet guide II

Comparing #35 with #36

Revision #36 was created by rackycz rackycz on Oct 3, 2020, 5:23:38 PM.

Decimal Integer formatter

Content

[...]
if (( $intStr . '.00' === (string) $value)) {
// If the input was decimal, but decimals were all zeros, it is an integer.
return $this->asInteger($value);
}
// All other situations
return$decimal = $this->asDecimal($value);     
 
    // Here I trim also the trailing zero.
 
    // Disadvantage is that String is returned, but in PDF it is not important
 
    return rtrim((string)$decimal, "0"); 
 
}

}
```

Usage is simple. Read the link above and give like to karpy47 or see below:
[...]