i read the filr into an array using file().
some of the lines are empty. i would like to output the file but
ignoring the emnpty lines. any ideas? 18 3073
steve wrote: "Piotr Wolski" wrote: > i read the filr into an array using file(). > some of the lines are empty. i would like to output the file but > ignoring the emnpty lines. any ideas?
foreach ($inarr as $out) { if ($out <> ’’) echo $out . "\n"; }
or instead of \n use <br> if writing to browser.
unfortunately it didint help. output is still the same.
$plik = fopen("wynik"," r");
$tablica = file('wynik');
foreach ($tablica as $out) {
if ($out <> ' ') echo $out."\n";
}
On Tue, 17 Aug 2004 11:31:19 -0500, Piotr Wolski wrote: steve wrote: "Piotr Wolski" wrote: > i read the filr into an array using file(). > some of the lines are empty. i would like to output the file but > ignoring the emnpty lines. any ideas? foreach ($inarr as $out) { if ($out <> '') echo $out . "\n"; }
or instead of \n use <br> if writing to browser. unfortunately it didint help. output is still the same.
$plik = fopen("wynik"," r"); $tablica = file('wynik');
foreach ($tablica as $out) { if ($out <> ' ') echo $out."\n";
^^ ^ }
m$ style "not" (<>) and a space you're checking against. Try:
foreach ($tablica as $out) {
if (strlen($out) > 0) echo "$out\n";
}
Note:
if ($out != '') echo "$out\n";
could also be used, depending on your preferred coding style =)
HTH.
Regards,
Ian
--
Ian.H
digiServ Network
London, UK http://digiserv.net/
Ian.H wrote: On Tue, 17 Aug 2004 11:31:19 -0500, Piotr Wolski wrote:
steve wrote:
"Piotr Wolski" wrote: > i read the filr into an array using file(). > some of the lines are empty. i would like to output the file but > ignoring the emnpty lines. any ideas?
foreach ($inarr as $out) { if ($out <> '') echo $out . "\n"; }
or instead of \n use <br> if writing to browser.
unfortunate ly it didint help. output is still the same.
$plik = fopen("wynik"," r"); $tablica = file('wynik');
foreach ($tablica as $out) { if ($out <> ' ') echo $out."\n";
^^ ^
} m$ style "not" (<>) and a space you're checking against. Try:
foreach ($tablica as $out) { if (strlen($out) > 0) echo "$out\n"; }
Note:
if ($out != '') echo "$out\n";
could also be used, depending on your preferred coding style =)
HTH. Regards,
Ian
i' wondering whats wrong cause the result is the same..
here is my code:
echo '<br><textarea name="show" rows=24 cols=40>';
exec($program." >wynik");
$plik = fopen("wynik"," r");
$tablica = file('wynik');
foreach ($tablica as $out) {
if (strlen($out)>0 ) echo $out;
}
echo '</textarea>';
end the output in textarea is still the same:
I = 0
J = 0
sum2 = 0.000000
sum = 0.000000
Alpha 1 = 0.000000
Alpha = NaN
total = 0
percentage is = 0.000000%
....
i dont want to have this empty lines..
Piotr Wolski <wo****@cs.purd ue.edu> wrote in message
news:<cf******* ***@mozo.cc.pur due.edu>... i read the filr into an array using file(). some of the lines are empty. i would like to output the file but ignoring the emnpty lines. any ideas?
$data = file('file.txt' );
foreach($data as $line) {
if (strlen(trim($l ine)) > 0) {
echo $line;
}
}
Cheers,
NC
"Piotr Wolski" <wo****@cs.purd ue.edu> wrote in message
news:cf******** **@mozo.cc.purd ue.edu... Ian.H wrote: On Tue, 17 Aug 2004 11:31:19 -0500, Piotr Wolski wrote:
steve wrote:
"Piotr Wolski" wrote: > i read the filr into an array using file(). > some of the lines are empty. i would like to output the file but > ignoring the emnpty lines. any ideas?
foreach ($inarr as $out) { if ($out <> '') echo $out . "\n"; }
or instead of \n use <br> if writing to browser.
unfortunate ly it didint help. output is still the same.
$plik = fopen("wynik"," r"); $tablica = file('wynik');
foreach ($tablica as $out) { if ($out <> ' ') echo $out."\n";
^^ ^
} m$ style "not" (<>) and a space you're checking against. Try:
foreach ($tablica as $out) { if (strlen($out) > 0) echo "$out\n"; }
Note:
if ($out != '') echo "$out\n";
could also be used, depending on your preferred coding style =)
HTH. Regards,
Ian i' wondering whats wrong cause the result is the same.. here is my code:
echo '<br><textarea name="show" rows=24 cols=40>';
exec($program." >wynik"); $plik = fopen("wynik"," r");
$tablica = file('wynik');
foreach ($tablica as $out) { if (strlen($out)>0 ) echo $out;
}
echo '</textarea>';
end the output in textarea is still the same: I = 0 J = 0 sum2 = 0.000000 sum = 0.000000 Alpha 1 = 0.000000 Alpha = NaN
total = 0
percentage is = 0.000000%
...
i dont want to have this empty lines..
Maybe try a simple regexp? Ex:
foreach ($tablica as $out) {
if ( strlen( $out ) > 0 && preg_match( "/\S/", $out, $tmp ) echo $out;
}
Nikolai Chuvakhin wrote: Piotr Wolski <wo****@cs.purd ue.edu> wrote in message news:<cf******* ***@mozo.cc.pur due.edu>...
i read the filr into an array using file(). some of the lines are empty. i would like to output the file but ignoring the emnpty lines. any ideas?
$data = file('file.txt' ); foreach($data as $line) { if (strlen(trim($l ine)) > 0) { echo $line; } }
Cheers, NC
yes, this is ok:). thank you very much, however i dont know why other
solutions were not correct.
Piotr Wolski wrote: Nikolai Chuvakhin wrote:
Piotr Wolski <wo****@cs.purd ue.edu> wrote in message news:<cf******* ***@mozo.cc.pur due.edu>...
i read the filr into an array using file(). some of the lines are empty. i would like to output the file but ignoring the emnpty lines. any ideas? $data = file('file.txt' ); foreach($data as $line) { if (strlen(trim($l ine)) > 0) { echo $line; } }
Cheers, NC
yes, this is ok:). thank you very much, however i dont know why other solutions were not correct.
if in my file for example in the middle of the file is a word "blabla".
How than i can find this word?
i'd like to use in inside this code if its possible and make this
"blabla" bold <b>:
$data = file('file.txt' ); foreach($data as $line) {
if (strlen(trim($l ine)) > 0) {
echo $line; } }
Piotr Wolski wrote: Piotr Wolski wrote:
Nikolai Chuvakhin wrote:
Piotr Wolski <wo****@cs.purd ue.edu> wrote in message news:<cf******* ***@mozo.cc.pur due.edu>...
i read the filr into an array using file(). some of the lines are empty. i would like to output the file but ignoring the emnpty lines. any ideas?
$data = file('file.txt' ); foreach($data as $line) { if (strlen(trim($l ine)) > 0) { echo $line; } }
Cheers, NC
yes, this is ok:). thank you very much, however i dont know why other solutions were not correct.
if in my file for example in the middle of the file is a word "blabla". How than i can find this word? i'd like to use in inside this code if its possible and make this "blabla" bold <b>:
$data = file('file.txt' ); foreach($data as $line) { if (strlen(trim($l ine)) > 0) { echo $line; } }
and one more question. can i somehow use html tags inside <textarea>
??for example i want to use <hr> tag. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: tornado |
last post by:
Hi all,
I am pretty new to PHP. I was reading PHP manual and trying out the
example from 2nd
chapter (A simple Tutorial). When i try to print the variable as
given in the example it returns
a empty value instead of returning the browser type.
Here is the line which i am using in my code and from manual:
<?php echo $_SERVER; ?>
|
by: ted |
last post by:
I'm having trouble using the re module to remove empty lines in a file.
Here's what I thought would work, but it doesn't:
import re
f = open("old_site/index.html")
for line in f:
line = re.sub(r'^\s+$|\n', '', line)
print line
|
by: mary |
last post by:
When we use
string line;
while (getline(in,line))
{
out.write(line.c_str(),line.size());
out.put('\n');
}
in.close();
|
by: Benny Eckert |
last post by:
Hi everyone,
There's probably an easy solution to this little problem, but I can't find
it:
in the properties of my field, i selected hide duplicates 'yes'. As a
(logical) result, i have a number of empty lines, where the said duplicates
used to be.
Is there a way to remove these empty lines?
|
by: Matthew Wieder |
last post by:
Hi - I have a datagrid that has a black header and the rows alternate
white and gray. The problem is that until items are added to the grid,
the grid appears as a large black rectangle, which is quite ugly. The
black area is larger then it is once an item is added. How can I solve
this problem either by:
A) Having only the header black and the rest of the empty block white or
gray (preffered solution)
B) Having the color gray or white...
| |
by: Sen Haerens |
last post by:
I'm using string.split(/^$/m, 2) on a curl output to separate header
and body. There’s an empty line between them. ^$ doesn’t seem to work...
Example curl output:
HTTP/1.1 404 Not Found
Date: Wed, 22 Feb 2006 00:01:45 GMT
Server: Apache/1.3.33 (Darwin) PHP/5.1.2 mod_perl/1.29
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1
|
by: Rico |
last post by:
Hello,
I'm formatting a report based on an existing controlled document. The
document that I'm duplicating has a number of lines that the user fills our
manually, but the database version of this document will fill the fields
with data rather than the user hand writing entries. The problem I'm
running into is when the last record prints, there are no more additional
lines (i.e. if the document has 15 lines to be filled out, and if I...
|
by: LEM |
last post by:
Hi,
I'm trying to remove any empty lines from a string, and I am doing the
following:
String pp;
pp = "\r\n\r\n1\r\n23\r\n\r\n4";
pp = pp.Replace("\r\n\r\n", "\r\n");
|
by: GS |
last post by:
How can one avoid capturing leading empty or blank lines?
the data I deal with look like this
"will be paid on the dates you specified.
xyz supplier
amount: $100.52 when: September 07, 2007 reference #: 0415
from: operating account
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |