Php print


 
Thread Tools Search this Thread
Top Forums Programming Php print
# 1  
Old 01-11-2013
Php print

i have a text file
Code:
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:39]
15728710[01/03/2013 18:16:39]
15728710[01/03/2013 18:16:39]
15728710[01/03/2013 18:16:39]
17825861[01/04/2013 18:32:20]


i writing a PHP that will set array index line by line and sort
Code:
<?php
$lines=file('C:\wamp\www\logAnalyzer\out.txt');
$lines=array();
$fp=fopen('out.txt', 'r');
while (!feof($fp))
{
    $line=fgets($fp);

    $line=trim($line);

    
    $lines[]=$line;

}
fclose($fp);
sort($lines);
$result = array_unique($lines);
  

foreach ($lines as $value) {
   echo $value."";
}


and the output i am getting
Code:
15728710[01/03/2013 18:16:35]15728710[01/03/2013 18:16:35]15728710[01/03/2013 18:16:35]15728710[01/03/2013 18:16:35]15728710[01/03/2013 18:16:35]15728710[01/03/2013 18:16:35]15728710[01/03/2013 18:16:35]15728710[01/03/2013 18:16:35]15728710[01/03/2013 18:16:35]15728710[01/03/2013 18:16:35]15728710[01/03/2013 18:16:35]15728710[01/03/2013 18:16:35]15728710[01/03/2013 18:16:35]15728710[01/03/2013 18:16:35]15728710[01/03/2013 18:16:35]15728710[01/03/2013 18:16:35]15728710[01/03/2013 18:16:35]15728710[01/03/2013 18:16:35]15728710[01/03/2013 18:16:35]15728710[01/03/2013 18:16:35]15728710[01/03/2013 18:16:35]15728710[01/03/2013 18:16:35]15728710[01/03/2013 18:16:35]15728710[01/03/2013 18:16:39]15728710[01/03/2013 18:16:39]15728710[01/03/2013 18:16:39]15728710[01/03/2013 18:16:39]16777377[01/08/2013 17:02:41]16777377[01/08/2013 17:02:41]16777377[01/08/2013 17:02:41]16777377[01/08/2013 17:02:41]16777377[01/08/2013 17:02:41]16777377[01/08/2013 17:02:41]16777377[01/08/2013 17:02:41]16777377[01/08/2013 17:02:41]16777377[01/08/2013 17:02:41]16777377[01/08/2013 17:02:41]16777377[01/08/2013 17:02:41]16777377[01/08/2013 17:02:41]16777377[01/08/2013 17:02:41]16777377[01/08/2013 17:02:41]16777377[01/08/2013 17:02:41]

i want the output
as in the input file or print line by line without displaying array index

---------- Post updated at 10:20 PM ---------- Previous update was at 10:07 PM ----------

i even tried
Code:
echo "<pre>";
print_r($lines);
echo "</pre>";

but the output is like
Code:
[0] => 
    [1] => 15728710[01/03/2013 18:16:35]
    [2] => 15728710[01/03/2013 18:16:35]
    [3] => 15728710[01/03/2013 18:16:35]
    [4] => 15728710[01/03/2013 18:16:35]
    [5] => 15728710[01/03/2013 18:16:35]
    [6] => 15728710[01/03/2013 18:16:35]
    [7] => 15728710[01/03/2013 18:16:35]
    [8] => 15728710[01/03/2013 18:16:35]
    [9] => 15728710[01/03/2013 18:16:35]
    [10] => 15728710[01/03/2013 18:16:35]
    [11] => 15728710[01/03/2013 18:16:35]
    [12] => 15728710[01/03/2013 18:16:35]
    [13] => 15728710[01/03/2013 18:16:35]
    [14] => 15728710[01/03/2013 18:16:35]
    [15] => 15728710[01/03/2013 18:16:35]
    [16] => 15728710[01/03/2013 18:16:35]
    [17] => 15728710[01/03/2013 18:16:35]
    [18] => 15728710[01/03/2013 18:16:35]
    [19] => 15728710[01/03/2013 18:16:35]
    [20] => 15728710[01/03/2013 18:16:35]
    [21] => 15728710[01/03/2013 18:16:35]
    [22] => 15728710[01/03/2013 18:16:35]
    [23] => 15728710[01/03/2013 18:16:35]
    [24] => 15728710[01/03/2013 18:16:39]
    [25] => 15728710[01/03/2013 18:16:39]
    [26] => 15728710[01/03/2013 18:16:39]
    [27] => 15728710[01/03/2013 18:16:39]
    [28] => 16777377[01/08/2013 17:02:41]
    [29] => 16777377[01/08/2013 17:02:41]
    [30] => 16777377[01/08/2013 17:02:41]
    [31] => 16777377[01/08/2013 17:02:41]
    [32] => 16777377[01/08/2013 17:02:41]
    [33] => 16777377[01/08/2013 17:02:41]
    [34] => 16777377[01/08/2013 17:02:41]


Last edited by navsan420; 01-11-2013 at 07:15 AM..
# 2  
Old 01-12-2013
Change this line from:
Code:
foreach ($lines as $value) {
   echo $value."";
}


To this and try it:
Code:
foreach ($lines as $value) {
   echo "$value\n";
}

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Solaris

Setting up Solaris 10 to print to a windows print server

Guys, I have a issue that I am trying to rectify please advise. lpstat -t shows scheduler is running printer lext644 disabled since Mon Dec 02 19:48:18 2013. available.I have restarted the printer service and it shows online but the above says disabled. I have a lot of jobs in the print... (1 Reply)
Discussion started by: terrywhitejr
1 Replies

2. UNIX for Dummies Questions & Answers

How to create a print filter that print text & image?

Currently, I have a print filter that takes a text file, that convert it into PCL which then gets to a HP printer. This works. Now I need to embedded a image file within the text file. I'm able to convert the image file into PCL and I can cat both files together to into a single document... (1 Reply)
Discussion started by: chedlee88-1
1 Replies

3. UNIX for Advanced & Expert Users

[Solved] remove all print jobs from a print queue

Hello, Sometimes i need to clear all the jobs of a print queue and it is really annoying to cancel one by one. Is there a way to cancel all print jobs for a specific print queue with a single command instead of cancelling them one by one? My AIX system is 5.3 Thank you for your attention (2 Replies)
Discussion started by: omonoiatis9
2 Replies

4. Shell Programming and Scripting

print first few lines, then apply regex on a specific column to print results.

abc.dat tty cpu tin tout us sy wt id 0 0 7 3 19 71 extended device statistics r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device 0.0 133.2 0.0 682.9 0.0 1.0 0.0 7.2 0 79 c1t0d0 0.2 180.4 0.1 5471.2 3.0 2.8 16.4 15.6 15 52 aaaaaa1-xx I want to skip first 5 line... (4 Replies)
Discussion started by: kchinnam
4 Replies

5. Shell Programming and Scripting

Howto Print File Path or Print the Filename

I'm trying to clean up my samba share and need to print the found file or print the path of the image it tried to searched for. So far I have this but can't seem to get the logic right. Can anyone help point me in the right direction? for FILE in `cat list`; do if ; then ... (1 Reply)
Discussion started by: overkill
1 Replies

6. HP-UX

Print Problem in UNIX. Need to know the option to specify the print paper size

Hi, Could any one please let me know what is the option available in UNIX to print by specifying the paper size? We are using Unix11i. I could n't see any option specified in the 'lp' command to print the report by specifying the size of the paper. It would be of great help to me, if... (1 Reply)
Discussion started by: ukarthik
1 Replies

7. Shell Programming and Scripting

How do I get awk to print a " in it's print part?

The line is simple, use " '{ print $1"]"$2"\"$3THE " NEEDS TO GO HERE$4 }' I've tried \", "\, ^" and '"" but none of it works. What am I missing? Putting in the [ between $1 and $2 works fine, I just need to do the same with a ". Thanks. (2 Replies)
Discussion started by: LordJezo
2 Replies

8. Shell Programming and Scripting

PHP & MySQL: sort desending and print

How do i get php to sort the times in a table and print order desending. eg: in the table i have: 02:60.00 02:70.00 02:20.00 02:50.00 in that order in a table how do i get php & mysql to print... (1 Reply)
Discussion started by: perleo
1 Replies
Login or Register to Ask a Question