How to get the number at a specified position in the Anqi CMS template?
get_digitThe filter can retrieve the digit at a specified position in the number, counting from the end of the number, with the starting position being 1.If the position to be obtained does not exist, return the entire number.If the original number is a number, then the result obtained is the number obtained by subtracting 48 from the ASCII value of the character at that position.
Usage method
get_digitHow to use the filter:
{{ obj|get_digit:number }}
For example, if you need to get1234567890To get the last 3rd digit, you can write it like this:
{{ 1234567890|get_digit:3 }}
# 显示结果
8
Example Demonstration
{{ 1234567890|get_digit:0 }}
{{ 1234567890|get_digit }}
{{ 1234567890|get_digit:2 }}
{{ 1234567890|get_digit:"4" }}
{{ 1234567890|get_digit:10 }}
{{ 1234567890|get_digit:15 }}
{{ "anqicms"|get_digit:2 }}
{{ "ANQICMS"|get_digit:2 }}
{{ "安企内容管理系统"|get_digit:2 }}
# 显示结果
1234567890
1234567890
9
7
1
1234567890
61
29
139