tags:

views:

63

answers:

3

Hi suppose I do have a text file with these lines

name: Mathew Age : 32 Country : USA Location : California bla bla bla....

What I want is I want a php code which can read this file and display result to a webpage.

+2  A: 

file() function reads a file into an array where one element represents a string in the file

kgb
+1  A: 

Display the actual text or remove the name:, etc?

Use the file() function (tutorial?) to read the file in and then echo out / process each line.

Josh K
+3  A: 

Use this code (untested):

$fp = fopen('filename.php');
while (!eof($fp)) {
    $line = fgets($fp);
    // Add code to display the values how you want
    echo $line."<br>";
}
fclose($fp);

That will loop through the file line by line. Each line will be assigned to the $line variable, and then you can manipulate and display the values how you would like.

Joseph