Page 1 of 1

txt with PHP

Posted: Thu Jul 08, 2010 10:16 pm
by emma23
HI!

I'm doing a little application using PHP, but I'm stuck because I have to read a text file (*. txt) that is where my information, and I present it, but I could not find the necessary algorithms for words, sentences or paragraphs in a specific area of the text file, but it has full

I hope it is clear

"I can do?

Re: txt with PHP

Posted: Thu Jul 08, 2010 11:52 pm
by DaveTheAve
http://php.net/explode -- Check it out. ;P

Code: Select all

<?php
$file = file_get_contents('NosePickerLog.txt');

//Have an array of sentaces:
$sentances = explode("\n",$file);

/*
array {
 [0] = 'Day 7/9/10',
 [1] = 'Time 10:50am',
 [2] = 'Left Nostile has a large rock it in'
 [...]
}
*/

//Have an array of words:
$words = explode(' ', $file);

/*
array {
 [0] = 'Day',
 [2] = '7/9/10',
 [3] = 'Time',
 [4] = '10:50am',
 [5] = 'Left',
 [6] = 'Nostile',
 [7] = 'has'
 [...]
}
*/