txt with PHP

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
emma23
Forum Newbie
Posts: 1
Joined: Thu Jul 08, 2010 10:02 pm

txt with PHP

Post 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?
User avatar
DaveTheAve
Forum Contributor
Posts: 385
Joined: Tue Oct 03, 2006 2:25 pm
Location: 127.0.0.1
Contact:

Re: txt with PHP

Post 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'
 [...]
}
*/

Post Reply