text does not wrap.

I need a good method for wrapping a text
Currently I am using textual_wrap(h(text),wrap_length)method but it is
not efficient some times it wrap text but some time not?
some time it wrap text like this
  e.g-
         hhfhhf fhhfhhf hfhhffhhf
         fjfnf dmfdfdd vdvf mvfv f vf vbfn bf bfbnf
         dkbmnfb mdnmnf nd
         kjngjkg frnfkjrngrg rngjrng rkgrkg vmmrg
         rlmgr lrglrg grgmrmg

I need a good method for wrapping a text
Currently I am using textual_wrap(h(text),wrap_length)method but it is
not efficient some times it wrap text but some time not?
some time it wrap text like this
e.g-
        hhfhhf fhhfhhf hfhhffhhf
        fjfnf dmfdfdd vdvf mvfv f vf vbfn bf bfbnf
        dkbmnfb mdnmnf nd
        kjngjkg frnfkjrngrg rngjrng rkgrkg vmmrg
        rlmgr lrglrg grgmrmg

I suspect that your text may contain newline/<br>'s which the textual_wrap is skipping over but you're still seeing them in the output?

Maybe if you strip all the newlines out of your text first and then wrap it?

Just a guess.