views:

43

answers:

1

Hey guys,
i am making one website.
In that, their is one section in which i have to do some manipulation on some string, and that string data will come from the database.

The things which i wanted on my string.

  1. First to check How many "<br>" tag character means how many line breaker are their in that string?"
  2. In between that tags[<br>], How many characters are their?
  3. Then if the characters are more then some size[ let take 20 character size], then they should see at the last.

my string is like this....

4-5 slices of toast(ready-made)
1/2 cup potatoes(boiled, peeled, chopped)
2 tbsp chana(boiled)
2 tbsp sprouted mung(boiled)
1/2 cup curd
1 tsp chaat masala
1 tsp aamchur masala
1 tsp red chilly powder
1/4 tsp black salt
4 tbsp onion chopped
4 tbsp tomatoes chopped
2 tbsp coriander chutney
2 tbsp mint chutney
1/2 cup date chutney
1 tsp jeera powder
4 tbsp coriander leaves
1 cup sev
Salt as per taste

now why i want like this bcz....

in this i have make two parts of this string and then i have to split in two section side by side.

now bcz the area in which this string will come, is not big size so big string parts like

1/2 cup potatoes(boiled, peeled, chopped)

should come at last, so my both side don't look messy.

and if i know how many line breakers are their then i can make two parts easily with equal size, so they look good side by side.

A: 

It's not particularly clear what you're asking, but if you're looking for some way to automatically insert the appropriate html into a string so that it looks good on a website, WordPress has a nice little function called wpautop() (WordPress AutoP) which works pretty well.

http://core.svn.wordpress.org/trunk/wp-includes/formatting.php - ctrl-f autop, it's like the 5th function

http://codex.wordpress.org/Function_Reference/wpautop

http://wordpress.org/tags/autop

dimo414