Difference between #35 and #36 of
Yii v2 snippet guide II

Revision #36 has been created by rackycz on Oct 3, 2020, 5:23:38 PM with the memo:

Decimal Integer formatter
« previous (#35) next (#37) »

Changes

Title unchanged

Yii v2 snippet guide II

Category unchanged

Tutorials

Yii version unchanged

2.0

Tags unchanged

tutorial,beginner,yii2,snippets

Content changed

[...]
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:
[...]
4 0
3 followers
Viewed: 75 380 times
Version: 2.0
Category: Tutorials
Written by: rackycz
Last updated by: rackycz
Created on: Aug 26, 2020
Last updated: 3 years ago
Update Article

Revisions

View all history