Thread: Add new line

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    11
    Rep Power
    0

    Add new line


    I have the following and am wanting to add a new line so each error is readable.

    Any ideas?.


    PHP Code:
    if($output ssh2_exec($connection"find /opt/open/logs/cust /opt/open/logs/oxi/oxix/ -type f -cmin -600 -exec grep Error {} \;")) {

        
    stream_set_blocking($outputtrue);
      
        echo 
    stream_get_contents($output);
    fclose($output);


    Thanks.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Location
    USA
    Posts
    4
    Rep Power
    0

    Add new line in php


    <?php echo "/n";?>
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    11
    Rep Power
    0
    Tried does not work, but thanks for suggestion....
  6. #4
  7. Mad Scientist
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2007
    Location
    North Yorkshire, UK
    Posts
    3,661
    Rep Power
    4123
    find and grep put things onto new lines anyway, so look in the source of the output - you'll probably see the new lines there.

    The rest of my response assumes that there are new lines present in the source, but you're just not seeing them on the 'page'

    Your browser will be treating the page as html, so new lines in the source are ignored. <br> is the line break tag in html

    If there is nothing else on the page then you could set the content type to be text/plain with

    PHP Code:
    header("Content-type: text/plain"); 
    at the top of the script - this would give you the plain text, which would preserve any new line charactors

    or

    do a PHP find and replace to find new lines ("\n") and replace with a line break tag ("<br />" or "\n<br />" to keep the source readable too) as part of the echo,

    eg

    echo stream_get_contents(str_replace("\n","\n<br />",$output));

    or

    echo this inside html <pre> tags
    I said I didn't like ORM!!! <?php $this->model->update($this->request->resources[0])->set($this->request->getData())->getData('count'); ?>

    PDO vs mysql_* functions: Find a Migration Guide Here

    [ Xeneco - T'interweb Development ] - [ Are you a Help Vampire? ] - [ Read The manual! ] - [ W3 methods - GET, POST, etc ] - [ Web Design Hell ]

IMN logo majestic logo threadwatch logo seochat tools logo