473,406 Members | 2,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Reading files into PHP

Hello,

how can I read files into PHP. I can make a listing of a directory, but
reading the file content into the PHP goes wrong.

==== script ==========
<?php
$handle=opendir('nieuws');
while (false!==($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$fp = fopen($file,"rb");
fpassthru($fp);
fclose($fp);
echo $fp;
echo "<HR>";
}
}
closedir($handle);
?>

===========

Thanx,

Marco J.L.
Jul 17 '05 #1
3 1100
NC
Marco J.L wrote:

how can I read files into PHP. I can make a listing of a directory,
but reading the file content into the PHP goes wrong.


Try this:

$handle = opendir('nieuws');
while (false!==($file = readdir($handle))) {
if ($file != "." && $file != "..") {
readfile($file);
echo "<HR>";
}
}
closedir($handle);

Cheers,
NC

Jul 17 '05 #2
On 2005-04-06, Marco J.L <lu******@yahoo.com.news> wrote:
how can I read files into PHP. I can make a listing of a directory, but
reading the file content into the PHP goes wrong.


file_get_contents() - check the manual.

--
Cheers
- Jacob Atzen
Jul 17 '05 #3

"Marco J.L" <lu******@yahoo.com.news> wrote in message
news:d3*********@reader10.wxs.nl...
Hello,

how can I read files into PHP. I can make a listing of a directory, but
reading the file content into the PHP goes wrong.

==== script ==========
<?php
$handle=opendir('nieuws');
while (false!==($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$fp = fopen($file,"rb");
fpassthru($fp);
fclose($fp);
echo $fp;
echo "<HR>";
}
}
closedir($handle);
?>

===========

Thanx,

Marco J.L.


array_map('readfile', glob('nieuws/*.*'));
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Olivier Maurice | last post by:
Hi all, I suppose some of you know the program Redmon (type redmon in google, first result). This neat little tool allows to hook up any functionality to a printer by putting the file printed...
19
by: Lionel B | last post by:
Greetings, I need to read (unformatted text) from stdin up to EOF into a char buffer; of course I cannot allocate my buffer until I know how much text is available, and I do not know how much...
1
by: Magnus | last post by:
allrite folks, got some questions here... 1) LAY-OUT OF REPORTS How is it possible to fundamentaly change the lay-out/form of a report in access? I dont really know it that "difficult", but...
6
by: Rajorshi Biswas | last post by:
Hi folks, Suppose I have a large (1 GB) text file which I want to read in reverse. The number of characters I want to read at a time is insignificant. I'm confused as to how best to do it. Upon...
2
by: nnimod | last post by:
Hi. I'm having trouble reading some unicode files. Basically, I have to parse certain files. Some of those files are being input in Japanese, Chinese etc. The easiest way, I figured, to distinguish...
7
by: jccorreu | last post by:
I've got to read info from multiple files that will be given to me. I know the format and what the data is. The thing is each time we run the program we may be using a differnt number of files,...
6
by: arne.muller | last post by:
Hello, I've come across some problems reading strucutres from binary files. Basically I've some strutures typedef struct { int i; double x; int n; double *mz;
10
by: Tyler | last post by:
Hello All: After trying to find an open source alternative to Matlab (or IDL), I am currently getting acquainted with Python and, in particular SciPy, NumPy, and Matplotlib. While I await the...
5
blazedaces
by: blazedaces | last post by:
Ok, so you know my problem, java is running out of memory reading with SAX, the event-based xml parser intended more-so than DOM for extremely large files. I'll try to explain what I've been doing...
4
by: Miner Jeff | last post by:
Hello, I have a basic question about reading files. I have several data files where the filenames are identical except for a short (3 character) prefix. I inherited this code and the person who...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.