Re: Manipulating strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ron Piggott wrote:
I have a series of questions.

How do I count the number of <br /> 's in a string?

How do I add text in the middle of a string, let's say after the 3rd
<br />

Ron


simplest way from experience is to simply explode('<br />', $the_string)
you can then count the array -1 for number of br's; and add text to the front and end of each; or indeed add/remove paragraphs before imploding it back together.

If you want more power, most would say use regex or str_ functions, however I'd recommend getting used to the DOMDocument to traverse the html and make fine grained adjustments.


regards,

--
nathan ( nathan@xxxxxxxxxxx )
{
  Senior Web Developer
  php + java + flex + xmpp + xml + ecmascript
  web development edinburgh | http://kraya.co.uk/
}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux