Jump to content

[SOLVED] How do i Break data up with new lines


perezf

Recommended Posts

Hello, I am currently trying to get data from a table in mysql

In one field i have data separated by new lines

How can i separate the data into bullets( meaning each new line a new bullet )

 

This is a sample of the data

Line 1 Test

Line 2 Test

Line 3 Test

Line 4 Test

Line 5 Test

What you could do is change your text file by making it something like...

 

| Line 1 Test | Line 2 Test | Line 3 Test | Line 4 Test | Line 5 Test

 

basically each line is seperated by '|'. Okay then in php you can do this...

 

<?php

$file= file_get_contents("file.txt"); //puts all the text/code from file.txt into one string;
$string= explode("|", $file); //seperates the line by looking for the | seperator.

for($i=0; $i < sizeof($string); $i++){
echo "• $string[$i] <br />"; //your string structure.
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.