How to cut a text ?
-
Hi, I have custom entries in the database that are filled with names of cities from visitors. Some write a blank before or after the cities name, some add an information like the state they are living in.
I have now a loop that sorts the cities and count, how often they are given, but if the name is that slightly different, it counts (of course) as a new city.
I already found a way to uppercase the first letter with the [format ucfirst] shortcode. But that doesn’t fix the count, but the display only.
Does anybody have an idea, how to cut these added blanks or states, so that they are count as one?[set total]0[/set] [set ort]Aachen[/set] [loop type=eintrag orderby=location fields=id] [pass vars] [if field=location value={ORT}] [calc]total = total + 1 [/calc] [else][get ort]: [get total] Eintr?ge [set ort][format ucfirst][field location][/format][/set] [calc]total = 1 [/calc] [/if] [/pass] [/loop]
This is an example for what comes out there. You see that we have one blank space, one of the entries was not with uppercase first letter and I don’t know exactly what is the problem of the other one.
Dresden: 5 Eintr?ge
Dresden : 5 Eintr?ge
Dresden: 4 Eintr?ge
Dresden: 1 Eintr?ge
- The topic ‘How to cut a text ?’ is closed to new replies.