www.webdeveloper.com
Results 1 to 3 of 3

Thread: justify text output

  1. #1
    Join Date
    Jul 2014
    Posts
    2

    justify text output

    I've managed to upload (thanks to the sticky post!) .csv file, process it, and display output ... but I'm puzzled how to make it look nice so it can be copied and pasted.

    It's indexed array of associative arrays, so I am doing output like this:

    PHP Code:
    for ($i=0$i<=count($filtered_array)-1$i++) {
      echo 
    $filtered_array[$i]['position'] . ") " $filtered_array[$i]['Title'] . " ---> " $filtered_array[$i]['URL'] . "<br />";

    output I get is:
    Code:
    1) Sanctum ---> http://www.imdb.com/title/tt0881320/
    2) Horrible Bosses ---> http://www.imdb.com/title/tt1499658/
    3) Pirates of the Caribbean: On Stranger Tides ---> http://www.imdb.com/title/tt1298650/
    4) Mission: Impossible - Ghost Protocol ---> http://www.imdb.com/title/tt1229238/
    5) Headhunters ---> http://www.imdb.com/title/tt1614989/

    I want it (when I right click output and choose "select all", copy it, and paste somewhere)
    to look nice, like this:
    Code:
    1) Sanctum                                     ---> http://www.imdb.com/title/tt0881320/
    2) Horrible Bosses                             ---> http://www.imdb.com/title/tt1499658/
    3) Pirates of the Caribbean: On Stranger Tides ---> http://www.imdb.com/title/tt1298650/
    4) Mission: Impossible - Ghost Protocol        ---> http://www.imdb.com/title/tt1229238/
    5) Headhunters                                 ---> http://www.imdb.com/title/tt1614989/

  2. #2
    Join Date
    Jul 2014
    Posts
    2
    dang those line breaks (why is there no "edit post" option ?!) ... but I hope I was clear enough.
    I checked now, right click output page and save as text file also work, but (like expected), file isn't justified

  3. #3
    Join Date
    Dec 2011
    Posts
    163
    Maybe something like this...
    PHP Code:
    for ($i=0$i<=count($filtered_array)-1$i++) {
      echo 
    "<div class=\"movie_row\">"
      echo 
    "<div class=\"movie\">" $filtered_array[$i]['position'] . ") " $filtered_array[$i]['Title']. "</div>";
      echo 
    "<div class=\"imdb\"> ---> " $filtered_array[$i]['URL'] . "</div><br />"
      echo 
    "</div>";

    HTML Code:
    <style type="text/css">
    div.movie_row div{
    float: left;
    }
    div.movie{
    width: 300px;
    }
    div.imdb{
    width: 150px;
    }
    </style>
    This is really just a rough code, but the idea is to have the div's containing the movie info to be at fixed widths and floated.
    The only thing I did not code in was that if a movie name takes up two or more lines, then the floating will mess up, to prevent this, each div.movie_row must be "clear:left;" afterwards.

    That's my two cents...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles