Jump to content

need help file_get_contents("test.txt");....

Go to solution Solved by Irate,

Recommended Posts

i am using this to get data frm text file......

text file content.

in php



and it working fine.

but here what i want.

text file content.

in php



so plz give me example how to get content.


Edited by ShivaGupta
Link to comment
Share on other sites

hint key word : explode

YA i found this  but their is no intrigation into text file.

$str = 'one,two,three,four';

// zero limit

// positive limit

// negative limit
Link to comment
Share on other sites

  • Solution

You want to open a file and read its context, then explode on it? Easy.



function gc($file) {
$stream = fopen($file,"r");
if(!feof($stream)) {
$content = file_get_contents($file);
$close = fclose($stream);
return $content;
} else { return false; }

$c = gc("test.txt");

if($c) {
$arr = explode(",",$c,2);
That should work.


Edit: And you can easily fetch the content from the array now.


$first = $array[0]; // "345"
$second = $array[1]; // "567"
$third = $array[2]; // "789"
Edited by Irate
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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.