Loop over chars in a string
-
I have a string in an XML file and I want to display each letter (or number) in a different box (
div
). So I made thediv
tag and I want to display one letter (or number) in it. Currently I have this code:...
name person
...
1Any advice on what I can improve? Because this isn't working. Thanks in advance!
-
I have a string in an XML file and I want to display each letter (or number) in a different box (
div
). So I made thediv
tag and I want to display one letter (or number) in it. Currently I have this code:...
name person
...
1Any advice on what I can improve? Because this isn't working. Thanks in advance!
1. Use $test as a constant. 2. Rename your param $text to something else, e.g. $sub_text and select="$text" (without this you have an empty string 3. Your if test is incorrect. count does not have a '$' in front of it. "not($count = string-length($text))" 4. The last parm $text should be renamed to $sub_text and select attrib set to "substring($text, $count + 1)" since you should be chopping off the first character and passing it to the next recursion.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
modified on Tuesday, June 7, 2011 7:55 PM