Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some simple filters added #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Cackenballz
Copy link

Hey Tom!

This is ClosetDeveloper from webdevRefinery and have been experimenting with some additional filters. As my screen name on your forums suggests, I'm no expert, so hopefully my simple code meets your approval. =)

Just adding some simple formatting filters where you can format with commas and specify a single argument for the number of decimals. The other filter does exactly the same, but in a percent format, also specifying decimal places (automatically formats with commas and adds the percent sign).

Let me know what you think or if I'm way off-base. Don't mean to waste your valuable time!

Aaron

@Cackenballz
Copy link
Author

Just thought about it and there's no format catcher in this code. That is, no check to make sure the $string in the filter is numeric. If the value is text, it would return zero, though, so maybe that's the responsibility of the user? Or, could add a check for !is_string() since is_numeric() will return true with a mixed type, whereas the number_format() function will return zero with that kind of string (unless it starts with a number, in which it will return the numbers up to the beginning text).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant