Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: help with echo

  1. #1
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help with echo

    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 codeIts 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();

  • #2
    Regular Coder
    Join Date
    Mar 2004
    Location
    Australia
    Posts
    217
    Thanks
    0
    Thanked 1 Time in 1 Post
    PHP Code:
    <?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.

  • #3
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    thanks

    thanks for the help , but i want to display the contents of the files(my fault, i said echo ) Is there any way to display the contents of the files next to each other, and not under one another?

  • #4
    Senior Coder
    Join Date
    Feb 2003
    Location
    Ontario, Canada
    Posts
    1,223
    Thanks
    0
    Thanked 0 Times in 0 Posts
    echo trim ($content);


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •