I am looking for some sort of a tutorial to open a file and display the entire contents of it. This should be easy i just havent found much telling me what i need.
Also, when editing a file is there a way to change multiple spaces to
example:
"he ll o" would output "he ll o"
so i would want the file to be saved as
"h ll o"
any easy way for that also?
Text to/from a file.
Moderator: General Moderators
Try this (untested)
For the other part of you question checkout the strtr-funktion.
Code: Select all
$fp = fopen("filename", r);
if($fp){
$cont = fread($fp, filesize("filename"));
flcose($fp);
}
echo $fp;- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
To replace all spaces with use str_replace():
When working with a file you can also use file() to read it into an array and foreach() to loop through the array and echo each line.
http://www.php.net/manual/en/ref.filesystem.php
Mac
Code: Select all
$non_breaking_spaces = str_replace(' ', ' ', $normal_spaces);http://www.php.net/manual/en/ref.filesystem.php
Mac