Help Please

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SidewinderX
Forum Contributor
Posts: 407
Joined: Fri Jul 16, 2004 9:04 pm
Location: NY

Help Please

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

try [php_man]nl2br[/php_man]
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

or a regular expression, even str_replace
SidewinderX
Forum Contributor
Posts: 407
Joined: Fri Jul 16, 2004 9:04 pm
Location: NY

Post 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.
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

replace the \n with <br> tags, str_replace

=]
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

thats what nl2br does..
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post 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
Post Reply