...

View Full Version : help with echo



piet3
07-04-2005, 10:46 PM
Hi all
Can anynone show me how to echo a variable without any line breaks i.e echo each variable alongside the other one(Note the variable is in a while loop).
Here is the code:(Its used to echo all files in a directory at once)

$d = dir("listings/");
while (false!== ($filename = $d->read())) { if (substr($filename, -4) == '.php')
{
$fp = fopen("listings/".$filename,"r");
$filesize = filesize("listings/".$filename);
$content = fread($fp,$filesize);
echo $content;} * THIS IS THE VRIABLE I WANT ALONGSIDE EACH OTHER, NOT UNDER EACH OTHER *
} $d->close();include_once'footer.php'; exit();

Serex
07-05-2005, 01:02 AM
<?php
$dir = "listings/";

if (is_dir($dir))
{
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false)
{
$name = explode(".", $file);
if ($name[1] == 'php')
{
echo "$file, ";
}
}
closedir($dh);
}
}
include_once('footer.php');
?>

rewrote your code... assuming your were only trying to echo a file if the filename ended in .php also seperates the files with a ',' insead of a break.

piet3
07-05-2005, 10:47 AM
thanks for the help , but i want to display the contents of the files(my fault, i said echo :o ) Is there any way to display the contents of the files next to each other, and not under one another?

AaronW
07-05-2005, 11:56 AM
echo trim ($content);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum