RE: [PHP] Recursive Replace

2002-10-02 Thread Jon Haworth

Hi Rick,

 How can I combine that line of code with 
 str_replace() or some other replace function 
 in order to turn \n into br for each line. 

I think you're looking for http://www.php.net/nl2br. Specifically:
 
  for ($i = 7; $i  sizeof($info); $i+=1)
echo nl2br($info[$i]); 


Cheers
Jon



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




RE: [PHP] Recursive Replace

2002-10-02 Thread Ford, Mike [LSS]

 -Original Message-
 From: Rick Beckman [mailto:[EMAIL PROTECTED]]
 Sent: 02 October 2002 12:12
 
 ? for ($i = 7; $i  sizeof($info); $i+=1) { echo $info[$i]; } ?
 
 That line of code successfully will display lines 7 and on of 
 an included
 text file into my HTML boilerplate. However, in my hundreds 
 of source text
 files, br is not included at the end of the lines, 
 therefore lines 7 and
 on appear as one chunk of text, rather than neatly formatted 
 lines. How can
 I combine that line of code with str_replace() or some other replace
 function in order to turn \n into br for each line. 

If it's genuinely one line per $info[] element, just add the dad-blamed br to your 
echo:

 ? for ($i = 7; $i  sizeof($info); $i+=1) { echo $info[$i], 'br'; } ?

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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




Re: [PHP] Recursive Replace

2002-10-02 Thread Rick Beckman

Thanks everyone! Works great! :-) If only I would have noticed how obvious
it was before trying making it more difficult than I had to.

-- 
Kyrie Eleison,
Rick
www.spiritsword.com/phpBB2/


Mike Ford wrote:
 -Original Message-
 From: Rick Beckman [mailto:[EMAIL PROTECTED]]
 Sent: 02 October 2002 12:12

 ? for ($i = 7; $i  sizeof($info); $i+=1) { echo $info[$i]; } ?

 That line of code successfully will display lines 7 and on of
 an included
 text file into my HTML boilerplate. However, in my hundreds
 of source text
 files, br is not included at the end of the lines,
 therefore lines 7 and
 on appear as one chunk of text, rather than neatly formatted
 lines. How can
 I combine that line of code with str_replace() or some other replace
 function in order to turn \n into br for each line.

 If it's genuinely one line per $info[] element, just add the
 dad-blamed br to your echo:

  ? for ($i = 7; $i  sizeof($info); $i+=1) { echo $info[$i], 'br';
 } ?

 Cheers!

 Mike

 -
 Mike Ford,  Electronic Information Services Adviser,
 Learning Support Services, Learning  Information Services,
 JG125, James Graham Building, Leeds Metropolitan University,
 Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
 Email: [EMAIL PROTECTED]
 Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211



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




RE: [PHP] Recursive Replace

2002-10-02 Thread John W. Holmes

 If it's genuinely one line per $info[] element, just add the
dad-blamed
 br to your echo:
 
  ? for ($i = 7; $i  sizeof($info); $i+=1) { echo $info[$i], 'br';
} ?
 

Also, just an FYI to the OP, you may want to calculate sizeof($info)
before hand, and use a variable in your for() statement. That way it
doesn't have to calculate sizeof() each loop...

---John Holmes...



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