Page 1 of 1

Help Please

Posted: Mon Sep 06, 2004 12:45 pm
by SidewinderX
Hello im doing a

Code: Select all

<?php $content = file_get_contents($url) ?>
then im doing a

Code: Select all

<?php strip_tags($content) ?>
when i do that to (lets use google for an example) it puts everything on one line

Google Web Images Groups News Froogle more ยป Advanced Search Preferences

how can i format that so i can make it like

Google Web
Images
Groups
News
Froogle

so each one has its seperate line

to see the full script you can go here
http://24.190.94.106:800/phpform.phps
to see it in action
http://24.190.94.106:800/phpform.php

Posted: Mon Sep 06, 2004 12:51 pm
by John Cartwright
try [php_man]nl2br[/php_man]

Posted: Mon Sep 06, 2004 2:11 pm
by tim
or a regular expression, even str_replace

Posted: Tue Sep 07, 2004 11:40 am
by SidewinderX
hmmm...i dont get it, let me give a better example (i think)

Code: Select all

<?php
$getstats = "Base Targets Destroyed 612 Flags Captured 1269 Flags Saved 256";
$stats = $getstats;
?>
This is just a simpler version of the actual script im making, using the string $stats how can I basically put a <br> before 'Flags Captured' and 'Flags Saved'....

To make it like
Base Targets Destroyed 612 <br>Flags Captured 1269 <br>Flags Saved 256
So it would look like
Base Targets Destroyed 612
Flags Captured 1269
Flags Saved 256
Note: The numbers dont remain constant

I also looked at str_replace , and couldnt figure out how that would work, if that is still the proper function could someone please give me a hand and give me an example.

Posted: Tue Sep 07, 2004 4:26 pm
by tim
replace the \n with <br> tags, str_replace

=]

Posted: Tue Sep 07, 2004 7:08 pm
by John Cartwright
thats what nl2br does..

Posted: Tue Sep 07, 2004 7:52 pm
by tim
I know what the function is phenom, he asked what to do with str_replace.

I would assume hes trying to learn other functions in hope for his/her better learning and perhaps needed usage at a future date.

most people dont know that /n and <br> are the same tags, just used in different enviroments