RE: [PHP] newline and return issues in string

2011-10-11 Thread admin
> -Original Message-
> From: Richard Quadling [mailto:rquadl...@gmail.com]
> Sent: Tuesday, October 11, 2011 9:44 AM
> To: ad...@buskirkgraphics.com
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] newline and return issues in string
> 
> On 11 October 2011 12:58,   wrote:
> > I have come across an issue with my string that I would like to find
> a
> > faster way to resolve.
> >
> > It seems there are new lines and returns at different positions of
> the
> > string.
> >
> >
> >
> > First I exploded on the new line explode(“\n”, $ string)
> >
> > This gave me a nice array but when I try to implode I get the new
> lines
> > again.
> >
> > There is not a consistent position and there seems to be some hidden
> returns
> > in the array as well.
> >
> >
> >
> > Is there a way, or has someone written a filter that would allow me
> to
> > remove all the newlines and returns from the array or string.
> >
> > Understand I have resolved this issue but I think I have to be going
> about
> > this the hard way because it is just too complex .
> >
> >
> >
> > FYI
> >
> > $filter = array("\r\n", "\n", "\r");
> >
> > str_replace($filter,’’,$string) ß this is useless in this situation I
> have
> > tried and it does not change the string at all.
> 
> You don't want to remove them. You want to replace them with a
> constant.
> 
> $lines = explode(PHP_EOL, str_replace($filter, PHP_EOL, $string));
> 
> for example.
> 
> 
> 
> 
> 
> --
> Richard Quadling
> Twitter : EE : Zend : PHPDoc
> @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea



Richard I am not sure I understand what that is doing it made things 300% worse.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] newline and return issues in string

2011-10-11 Thread Fatih P.

On 10/11/2011 04:44 PM, Richard Quadling wrote:

On 11 October 2011 12:58,  wrote:

I have come across an issue with my string that I would like to find a
faster way to resolve.

It seems there are new lines and returns at different positions of the
string.



First I exploded on the new line explode(“\n”, $ string)

This gave me a nice array but when I try to implode I get the new lines
again.

There is not a consistent position and there seems to be some hidden returns
in the array as well.



Is there a way, or has someone written a filter that would allow me to
remove all the newlines and returns from the array or string.

Understand I have resolved this issue but I think I have to be going about
this the hard way because it is just too complex .



FYI

$filter = array("\r\n", "\n", "\r");

str_replace($filter,’’,$string) ß this is useless in this situation I have
tried and it does not change the string at all.

You don't want to remove them. You want to replace them with a constant.

$lines = explode(PHP_EOL, str_replace($filter, PHP_EOL, $string));

for example.







try to implement a string builder using array or arrayobject and on 
insert; filter / replace your text / characters using regex,



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] newline and return issues in string

2011-10-11 Thread Richard Quadling
On 11 October 2011 12:58,   wrote:
> I have come across an issue with my string that I would like to find a
> faster way to resolve.
>
> It seems there are new lines and returns at different positions of the
> string.
>
>
>
> First I exploded on the new line explode(“\n”, $ string)
>
> This gave me a nice array but when I try to implode I get the new lines
> again.
>
> There is not a consistent position and there seems to be some hidden returns
> in the array as well.
>
>
>
> Is there a way, or has someone written a filter that would allow me to
> remove all the newlines and returns from the array or string.
>
> Understand I have resolved this issue but I think I have to be going about
> this the hard way because it is just too complex .
>
>
>
> FYI
>
> $filter = array("\r\n", "\n", "\r");
>
> str_replace($filter,’’,$string) ß this is useless in this situation I have
> tried and it does not change the string at all.

You don't want to remove them. You want to replace them with a constant.

$lines = explode(PHP_EOL, str_replace($filter, PHP_EOL, $string));

for example.





-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] newline and return issues in string

2011-10-11 Thread admin
> -Original Message-
> From: Bastien Koert [mailto:phps...@gmail.com]
> Sent: Tuesday, October 11, 2011 8:53 AM
> To: ad...@buskirkgraphics.com
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] newline and return issues in string
> 
> On Tue, Oct 11, 2011 at 7:58 AM,   wrote:
> > I have come across an issue with my string that I would like to find
> a
> > faster way to resolve.
> >
> > It seems there are new lines and returns at different positions of
> the
> > string.
> >
> >
> >
> > First I exploded on the new line explode(“\n”, $ string)
> >
> > This gave me a nice array but when I try to implode I get the new
> lines
> > again.
> >
> > There is not a consistent position and there seems to be some hidden
> returns
> > in the array as well.
> >
> >
> >
> > Is there a way, or has someone written a filter that would allow me
> to
> > remove all the newlines and returns from the array or string.
> >
> > Understand I have resolved this issue but I think I have to be going
> about
> > this the hard way because it is just too complex .
> >
> >
> >
> > FYI
> >
> > $filter = array("\r\n", "\n", "\r");
> >
> > str_replace($filter,’’,$string) ß this is useless in this situation I
> have
> > tried and it does not change the string at all.
> >
> > Understand the newlines and returns do not display in the string as
> > literals. Meaning you do not see /n or /r it is hidden.
> >
> >
> >
> >
> >
> >
> 
> What about using nl2br() and then stripping out all the  tags?
> 
> --
> 
> Bastien
> 
> Cat, the other other white meat

I tried that but same issue



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] newline and return issues in string

2011-10-11 Thread Bastien Koert
On Tue, Oct 11, 2011 at 7:58 AM,   wrote:
> I have come across an issue with my string that I would like to find a
> faster way to resolve.
>
> It seems there are new lines and returns at different positions of the
> string.
>
>
>
> First I exploded on the new line explode(“\n”, $ string)
>
> This gave me a nice array but when I try to implode I get the new lines
> again.
>
> There is not a consistent position and there seems to be some hidden returns
> in the array as well.
>
>
>
> Is there a way, or has someone written a filter that would allow me to
> remove all the newlines and returns from the array or string.
>
> Understand I have resolved this issue but I think I have to be going about
> this the hard way because it is just too complex .
>
>
>
> FYI
>
> $filter = array("\r\n", "\n", "\r");
>
> str_replace($filter,’’,$string) ß this is useless in this situation I have
> tried and it does not change the string at all.
>
> Understand the newlines and returns do not display in the string as
> literals. Meaning you do not see /n or /r it is hidden.
>
>
>
>
>
>

What about using nl2br() and then stripping out all the  tags?

-- 

Bastien

Cat, the other other white meat

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] newline and return issues in string

2011-10-11 Thread admin
I have come across an issue with my string that I would like to find a
faster way to resolve.

It seems there are new lines and returns at different positions of the
string. 

 

First I exploded on the new line explode(“\n”, $ string)

This gave me a nice array but when I try to implode I get the new lines
again.

There is not a consistent position and there seems to be some hidden returns
in the array as well.

 

Is there a way, or has someone written a filter that would allow me to
remove all the newlines and returns from the array or string.

Understand I have resolved this issue but I think I have to be going about
this the hard way because it is just too complex .

 

FYI

$filter = array("\r\n", "\n", "\r");

str_replace($filter,’’,$string) ß this is useless in this situation I have
tried and it does not change the string at all.

Understand the newlines and returns do not display in the string as
literals. Meaning you do not see /n or /r it is hidden.

 

 



Re: [PHP] Newline

2007-10-30 Thread hochprior

"Nathan Nobbe" wrote:

On 10/29/07, Crayon Shin Chan <[EMAIL PROTECTED]> wrote:


On Sunday 28 October 2007, magoo wrote:


I have switched to using single quotes, and found out that newline
(\n) only works in double quotes. It looks kind of stupid using
'someString'."\n"; and it`s kind of inconsistent using double quotes
for some lines like "someString\n";.

if you were going to do that you may as well use PHP_EOL
its cross-platform and doesnt require an define directive.
(php5 only)


Thanks for that Nathan! I didn`t know that constant.
Using that looks pretty neat in my eyes.

--
Kind regards,
hochprior

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Newline

2007-10-29 Thread Nathan Nobbe
On 10/30/07, Crayon Shin Chan <[EMAIL PROTECTED]> wrote:
>
> On Monday 29 October 2007, Nathan Nobbe wrote:
> > if you were going to do that you may as well use PHP_EOL
> > its cross-platform and doesnt require an define directive.
> > (php5 only)
>
> It's available in 4.3.10 as well,


youre right about that; my mistake.

but manual doesn't specify what it
> defines -


let the source tell it:
phpunpack/php5.2-200708051230/NEWS:2867:- Added PHP_EOL constant that
contains the OS way of representing newlines.

 47 #ifdef PHP_WIN32
 48 #include "tsrm_win32.h"
 49 #include "win95nt.h"
 50 #   ifdef PHP_EXPORTS
 51 #   define PHPAPI __declspec(dllexport)
 52 #   else
 53 #   define PHPAPI __declspec(dllimport)
 54 #   endif
 55 #define PHP_DIR_SEPARATOR '\\'
 56 #define PHP_EOL "\r\n"
 57 #else
 58 #define PHPAPI
 59 #define THREAD_LS
 60 #define PHP_DIR_SEPARATOR '/'
 61 #if defined(__MacOSX__)
 62 #define PHP_EOL "\r"
 63 #else
 64 #define PHP_EOL "\n"
 65 #endif
 66 #endif

I suppose I can echo or vardump it to find out.


a little trickier than you might guess :

php > var_dump(PHP_EOL);
string(1) "
"

Also manual
> doesn't mention "cross-platform", in any case even if it
> is "cross-platform" it seems pointless because how does PHP know which
> environment the output is going to be used in?


its supposed to be used for the command line;
theoretically the output will land on the same system from which its
generated.
however, coming from my linux box; this was correctly interpreted by
internet explorer

result when viewing source was
blah
blah

I define 'CR', 'LF', 'CRLF' and use them as circumstances dictate.


the use of that definitely depends upon the circumstances; ill stick w/ the
predefined constant until i run into a problem ;)

-nathan


Re: [PHP] Newline

2007-10-29 Thread Crayon Shin Chan
On Monday 29 October 2007, Nathan Nobbe wrote:
> if you were going to do that you may as well use PHP_EOL
> its cross-platform and doesnt require an define directive.
> (php5 only)

It's available in 4.3.10 as well, but manual doesn't specify what it 
defines - I suppose I can echo or vardump it to find out. Also manual 
doesn't mention "cross-platform", in any case even if it 
is "cross-platform" it seems pointless because how does PHP know which 
environment the output is going to be used in? I 
define 'CR', 'LF', 'CRLF' and use them as circumstances dictate.

-- 
Crayon

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Newline

2007-10-29 Thread Jeremy Mcentire
In general, I try to think of single quotes as being literal and  
double quotes as being interpreted.


In that case, we expect 'some line\t with a tab, a variable {$obj- 
>member}, and a newline\n' to produce exactly:

some line\t with a tab, a variable {$obj->member}, and a newline\n

Yet, the same thing in double quotes:
some linewith a tab, a variable foo, and a
 newline

As a result, I use single quotes whenever I can.  Otherwise, double.

Jeremy Mcentire
Ant Farmer
ZooToo LLC


On Oct 29, 2007, at 6:15 AM, Nathan Nobbe wrote:


On 10/29/07, Crayon Shin Chan <[EMAIL PROTECTED]> wrote:


On Sunday 28 October 2007, magoo wrote:

I have switched to using single quotes, and found out that  
newline (\n)

only works in double quotes. It looks kind of stupid using
'someString'."\n"; and it`s kind of inconsistent using double quotes
for some lines like "someString\n";.


You can:

define('LF', "\n");

then

echo 'A newline' . LF;

or something



if you were going to do that you may as well use PHP_EOL
its cross-platform and doesnt require an define directive.
(php5 only)

-nathan


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Newline

2007-10-29 Thread Nathan Nobbe
On 10/29/07, Crayon Shin Chan <[EMAIL PROTECTED]> wrote:
>
> On Sunday 28 October 2007, magoo wrote:
>
> > I have switched to using single quotes, and found out that newline (\n)
> > only works in double quotes. It looks kind of stupid using
> > 'someString'."\n"; and it`s kind of inconsistent using double quotes
> > for some lines like "someString\n";.
>
> You can:
>
> define('LF', "\n");
>
> then
>
> echo 'A newline' . LF;
>
> or something


if you were going to do that you may as well use PHP_EOL
its cross-platform and doesnt require an define directive.
(php5 only)

-nathan


Re: [PHP] Newline

2007-10-29 Thread Crayon Shin Chan
On Sunday 28 October 2007, magoo wrote:

> I have switched to using single quotes, and found out that newline (\n)
> only works in double quotes. It looks kind of stupid using
> 'someString'."\n"; and it`s kind of inconsistent using double quotes
> for some lines like "someString\n";.

You can:

define('LF', "\n");

then

echo 'A newline' . LF;

or something

-- 
Crayon

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Newline

2007-10-28 Thread heavyccasey
I use

echo 'Blah blah
blah blah


blah.';

On 10/28/07, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
> On 10/28/07, magoo <[EMAIL PROTECTED]> wrote:
> >
> > Hi NG!
> >
> > I have switched to using single quotes, and found out that newline (\n)
> > only
> > works in double quotes. It looks kind of stupid using 'someString'."\n";
> > and
> > it`s kind of inconsistent using double quotes for some lines like
> > "someString\n";.
> > What`s the best way to get a consitent code?
> >
>
> choose the string syntax that best fits the purpose of the given string.
> if a string will not have variables embedded in it, or special characters,
> use
> single quotes.  if it will, use double quotes.
> if you have a particularly long string, with variables and special
> characters
> consider Heredoc.
>
> -nathan
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Newline

2007-10-28 Thread Nathan Nobbe
On 10/28/07, magoo <[EMAIL PROTECTED]> wrote:
>
> Hi NG!
>
> I have switched to using single quotes, and found out that newline (\n)
> only
> works in double quotes. It looks kind of stupid using 'someString'."\n";
> and
> it`s kind of inconsistent using double quotes for some lines like
> "someString\n";.
> What`s the best way to get a consitent code?
>

choose the string syntax that best fits the purpose of the given string.
if a string will not have variables embedded in it, or special characters,
use
single quotes.  if it will, use double quotes.
if you have a particularly long string, with variables and special
characters
consider Heredoc.

-nathan


[PHP] Newline

2007-10-28 Thread magoo

Hi NG!

I have switched to using single quotes, and found out that newline (\n) only 
works in double quotes. It looks kind of stupid using 'someString'."\n"; and 
it`s kind of inconsistent using double quotes for some lines like 
"someString\n";.

What`s the best way to get a consitent code?

--
Kind regards,
magoo 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Newline and tab characters

2007-03-26 Thread Richard Lynch
On Mon, March 26, 2007 6:54 am, Arno Kuhl wrote:
> I've just noticed that "\r\n" and "\t" characters create a space when
> rendered in the browser (tested in IE and Firefox). I'd always thought
> the
> browser would ignore these characters.

No.

HTML "collapses" any run of whitespace to a single space character.

It does something akin to:
$html = preg_replace("|\\s+|", " ", $html);
on each chunk of non-tag content.

It does not ever "ignore" whitespace in content.

> This wouldn't normally be a
> problem
> but the wysiwyg html editor in the cms I'm using tries to be friendly
> by
> formatting the html code, so something like
>
> get #33\">online
>
> becomes
>
> \r\n\t\tget\r\n\t\t style=\"COLOR: #33\">online

Your WYSIWIG tool is very broken, if the above is correct, since it is
ADDING a bunch of whitespace inside the content.

> Is there a simple way to sort this out or do I need to create a
> function to
> strip these characters before display, checking first that they don't
> occur
> within a  tag in which case I mustn't strip them.

I'm betting that you have not correctly analyzed what is going on yet,
first and foremost.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Newline and tab characters

2007-03-26 Thread Zoltán Németh
2007. 03. 26, hétfő keltezéssel 13.58-kor Zoltán Németh ezt írta:
> 2007. 03. 26, hétfő keltezéssel 13.54-kor Arno Kuhl ezt írta:
> > I've just noticed that "\r\n" and "\t" characters create a space when
> > rendered in the browser (tested in IE and Firefox). I'd always thought the
> > browser would ignore these characters. This wouldn't normally be a problem
> > but the wysiwyg html editor in the cms I'm using tries to be friendly by
> > formatting the html code, so something like
> > 
> > get > #33\">online
> > 
> > becomes
> > 
> > \r\n\t\tget\r\n\t\t > style=\"COLOR: #33\">online
> > 
> > and instead of being displayed as getonline it's displayed as get online.
> > 
> > Is there a simple way to sort this out or do I need to create a function to
> > strip these characters before display, checking first that they don't occur
> > within a  tag in which case I mustn't strip them.
> 
> why not strip them before storing the html content into the DB?
> that way you need to strip them only once, while if you strip them on
> display you need to strip them once for each request.
> and you don't need checking with  tags and stuff.
> just do a 
> str_replace(array("\n", "\r", "\t"), "", $text);
> on it and that's all

err, sorry I misunderstood your sentence about the  tags...
yeah, you should somehow avoid replacing within  tags. maybe in
first step find all  tags, save their contents in an array, then do
the str_replace, and after that restore the  tags contents with
preg_replace

greets
Zoltán Németh

> 
> greets
> Zoltán Németh
> 
> > 
> > TIA
> > Arno
> > 
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Newline and tab characters

2007-03-26 Thread Zoltán Németh
2007. 03. 26, hétfő keltezéssel 13.54-kor Arno Kuhl ezt írta:
> I've just noticed that "\r\n" and "\t" characters create a space when
> rendered in the browser (tested in IE and Firefox). I'd always thought the
> browser would ignore these characters. This wouldn't normally be a problem
> but the wysiwyg html editor in the cms I'm using tries to be friendly by
> formatting the html code, so something like
> 
> get #33\">online
> 
> becomes
> 
> \r\n\t\tget\r\n\t\t style=\"COLOR: #33\">online
> 
> and instead of being displayed as getonline it's displayed as get online.
> 
> Is there a simple way to sort this out or do I need to create a function to
> strip these characters before display, checking first that they don't occur
> within a  tag in which case I mustn't strip them.

why not strip them before storing the html content into the DB?
that way you need to strip them only once, while if you strip them on
display you need to strip them once for each request.
and you don't need checking with  tags and stuff.
just do a 
str_replace(array("\n", "\r", "\t"), "", $text);
on it and that's all

greets
Zoltán Németh

> 
> TIA
> Arno
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Newline and tab characters

2007-03-26 Thread Arno Kuhl
I've just noticed that "\r\n" and "\t" characters create a space when
rendered in the browser (tested in IE and Firefox). I'd always thought the
browser would ignore these characters. This wouldn't normally be a problem
but the wysiwyg html editor in the cms I'm using tries to be friendly by
formatting the html code, so something like

getonline

becomes

\r\n\t\tget\r\n\t\tonline

and instead of being displayed as getonline it's displayed as get online.

Is there a simple way to sort this out or do I need to create a function to
strip these characters before display, checking first that they don't occur
within a  tag in which case I mustn't strip them.

TIA
Arno

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Newline Before XML Document

2006-12-12 Thread Ray Hauge
I found the problem.

I was re-writing the page from using the old DOMXML to the new DOM.  We
recently switched to PHP5, and there's only one script (so far) that
creates XML, so it was easier to just use the domxml-php4-to-php5.php
class that is available online.  I didn't realize that there was an
extra line after the closing '?>' in that file.  That was causing the
extra "invisible" line to show up.

--
Ray Hauge
Application Development Lead
American Student Loan Services
www.americanstudentloan.com

-Original Message-
From: Ray Hauge 
Sent: Tuesday, December 12, 2006 9:14 AM
To: php-general@lists.php.net
Subject: [PHP] Newline Before XML Document

I've read a lot of information about this error (in Firefox):

 

XML Parsing Error: xml declaration not at start of external entity

 

Basically it means that the XML did not start at the beginning of the
file.  The weird part of this is that if I save the document to a file
on the webroot and then view it that way, the XML is displayed
correctly.

 

So far I've tried using output buffering to make sure no other
information was sent before I output the XML, but that didn't work.
I've also tried replacing all return characters and newline characters,
but that also didn't work.

 

In Konqueror I get the following error message:

 

fatal parsing error: invalid name for processing instruction in line 2,
column 6



 

I even tried the following on the ob_get_contents():

$xml_string = substr($xml_string, strstr($xml_string, '<'));

 

Has anyone else run into this problem?  As far as I can tell this
document starts on line 1.

 

Thanks,

--

Ray Hauge

Application Development Lead

American Student Loan Services

www.americanstudentloan.com

 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Newline Before XML Document

2006-12-12 Thread Ray Hauge
I've read a lot of information about this error (in Firefox):

 

XML Parsing Error: xml declaration not at start of external entity

 

Basically it means that the XML did not start at the beginning of the
file.  The weird part of this is that if I save the document to a file
on the webroot and then view it that way, the XML is displayed
correctly.

 

So far I've tried using output buffering to make sure no other
information was sent before I output the XML, but that didn't work.
I've also tried replacing all return characters and newline characters,
but that also didn't work.

 

In Konqueror I get the following error message:

 

fatal parsing error: invalid name for processing instruction in line 2,
column 6



 

I even tried the following on the ob_get_contents():

$xml_string = substr($xml_string, strstr($xml_string, '<'));

 

Has anyone else run into this problem?  As far as I can tell this
document starts on line 1.

 

Thanks,

--

Ray Hauge

Application Development Lead

American Student Loan Services

www.americanstudentloan.com

 



Re: [PHP] Newline character problem...

2005-12-03 Thread tg-php
In addition to what was mentioned below, you can also wrap your text in 
 tags to have it output exactly as you've formatted it:

echo "\n";
echo "one\n";
echo "two\n";
echo "\n";

Actually, I don't think either of these methods is going to output what you 
want.  Even though \n is newline, it's still interpreted as newline/carriage 
return.   Unix, Mac and DOS/Windows PC's all use something different for a 
newline character.  I believe Unix was \n, Mac was \r at some point and 
DOS/Windows PC's used \n\r.  Think my old Amiga used \r as well.  Goofy.

Anyway, it's proably because of this that you can't just do \n and expect it to 
be represented as just a newline (sans carriage return).

If you use the  tag, then you can manually do what you want to do:

echo "\n";
echo "one\n";
echo "   two";
echo "\n";


If you don't use the  tag, there's an HTML entity that you can use for a 
hard space..      Unfortunately in HTML, if you stack a bunch of spaces, 
it compresses them to one space.

echo "onetwo";
..and..
echo "one two";

Will both result in:
one two

If you use   instead of spaces, it'll space it out further:

echo "one   two";

Ugly but it works.

Unfortunately (again), if you don't use the  tags, you'll have to remember 
to set a monospace font face or you won't get the text alignment you might want.


One other side nugget related to this (formatted and spaces and all that 
nonsense), you can use the  tag to tell HTML not to word-wrap the 
text within it.  Comes in handy when you want to force a column heading to be 
one line even though it's got a space in it and your browser wants to wrap the 
line.

Good luck! Hope this helped a little.

-TG

= = = Original message = = =

Robert napisal(a):
> I'm new to PHP but not programming in general. I have used C++ for a while
> and I'm familiar with the newline character as it's basically the same in
> PHP.
> This is the most basic of examples:
> print 'one' ;
> print "\n" ;
> print 'two' ;
> 
> The output of this when accessed on my server is: one two
> It should be: one
>two

Hi
well this isn't apache or php related, as it's webbrowser related, and 
even more, it's correct.

The thing is, what You see in Your browser is an interpreted version of 
the html outputed by the php (obvious?), so if You do a html file, and put:
one
two
in there, and view it with Your browser, it will still look like this:
one two
to get the expected (as in C/C++) result, You need to add a  or any 
other line breaking method in there (onetwo is another one)
Now, if You'd see the generated source code, You'd notice that there is 
in fact the line break as it should be :)
so it is good to use '\n' to get the output code clear to read, for 
debugging and so..

Best wishes
?ukasz Hejnak


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Newline character problem...

2005-12-02 Thread ?ukasz Hejnak

Robert napisal(a):

I'm new to PHP but not programming in general. I have used C++ for a while
and I'm familiar with the newline character as it's basically the same in
PHP.
This is the most basic of examples:
print 'one' ;
print "\n" ;
print 'two' ;

The output of this when accessed on my server is: one two
It should be: one
   two


Hi
well this isn't apache or php related, as it's webbrowser related, and 
even more, it's correct.


The thing is, what You see in Your browser is an interpreted version of 
the html outputed by the php (obvious?), so if You do a html file, and put:

one
two
in there, and view it with Your browser, it will still look like this:
one two
to get the expected (as in C/C++) result, You need to add a  or any 
other line breaking method in there (onetwo is another one)
Now, if You'd see the generated source code, You'd notice that there is 
in fact the line break as it should be :)
so it is good to use '\n' to get the output code clear to read, for 
debugging and so..


Best wishes
?ukasz Hejnak

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Newline character problem...

2005-12-02 Thread Robert
I'm new to PHP but not programming in general. I have used C++ for a while
and I'm familiar with the newline character as it's basically the same in
PHP. Whenever I print something with a newline character in it all it
produces is a space between whatever two things I'm printing. I'm running
php 5.1.1 running on FreeBSD 6 with apache 2.2.0. All the latest versions
installed today.

This is the most basic of examples:

print 'one' ;
print "\n" ;
print 'two' ;

The output of this when accessed on my server is: one two
It should be: one
   two

I've tried using printf as well but to no avail. It just adds a space
between the outputs. I've also tried using different browsers but still get
the same result. What am I doing wrong? Could this a php configuration
issue? Apache maybe?

Thanks,

Rob


Re: [PHP] newline and pregreplace

2005-07-01 Thread Dotan Cohen
On 7/2/05, Richard Lynch <[EMAIL PROTECTED]> wrote:
> On Fri, July 1, 2005 3:35 am, Dotan Cohen said:
> > By the way, I see that you advertise offices on all the planets and
> > most of the major moons, but when I try to get in contact with the
> > Uranus branch, I'm told that the nearest operating office is on Earth.
> > There's 3 planets and over 20 big moons between those planets, why the
> > gap in coverage?
> 
> Because I cannot remember any fictional character who lived on Uranus (or
> many of the other planets) to fix my site up.
> 
> In theory, it would tell you that our Uranus representative is [insert
> fictional character here] at [insert fictional address here].
> 
> It would STILL direct you to our Earth office, since our analysis of your
> IP address indicates that would be closer to you.
> 
> Anybody sci-fi buffs wanna help me out with a suggestion for a fictional
> character to be my representative on their home planets?
> 
> I got Luna (aka the Moon) covered with Adam Selene of Luna City. I've even
> got his address written down somewhere here.
> 
> How come I never have the time/money to fix up my own sites?  Is that just
> me? :-)
> 
> --
> Like Music?
> http://l-i-e.com/artists.htm
> 

STFW:
http://www.east-haven.k12.ct.us/eha/alien/alien8/uranuscs/uranuscs.htm
http://www.cssd.ab.ca/tech/science/alien/titania.htm

I should mention that Nukka is great on the barbeque, but you have to
cut away a lot of fat.

This is getting as OT as the 2-stroke thread...

Dotan
http://lyricslist.com/lyrics/artist_albums/156/destiny_s_child.php
Destiny's Child Song Lyrics

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] newline and pregreplace

2005-07-01 Thread Richard Lynch
On Fri, July 1, 2005 3:35 am, Dotan Cohen said:
> By the way, I see that you advertise offices on all the planets and
> most of the major moons, but when I try to get in contact with the
> Uranus branch, I'm told that the nearest operating office is on Earth.
> There's 3 planets and over 20 big moons between those planets, why the
> gap in coverage?

PS

Didja notice that if you re-load, the planet alignment changes in
real-time to show you a view of our Solar System from a randomly-selected
point in Space? :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] newline and pregreplace

2005-07-01 Thread Richard Lynch
On Fri, July 1, 2005 3:35 am, Dotan Cohen said:
> By the way, I see that you advertise offices on all the planets and
> most of the major moons, but when I try to get in contact with the
> Uranus branch, I'm told that the nearest operating office is on Earth.
> There's 3 planets and over 20 big moons between those planets, why the
> gap in coverage?

Because I cannot remember any fictional character who lived on Uranus (or
many of the other planets) to fix my site up.

In theory, it would tell you that our Uranus representative is [insert
fictional character here] at [insert fictional address here].

It would STILL direct you to our Earth office, since our analysis of your
IP address indicates that would be closer to you.

Anybody sci-fi buffs wanna help me out with a suggestion for a fictional
character to be my representative on their home planets?

I got Luna (aka the Moon) covered with Adam Selene of Luna City. I've even
got his address written down somewhere here.

How come I never have the time/money to fix up my own sites?  Is that just
me? :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] newline and pregreplace

2005-07-01 Thread Dotan Cohen
On 7/1/05, Richard Lynch <[EMAIL PROTECTED]> wrote:
> On Fri, June 24, 2005 3:18 pm, Dotan Cohen said:
> > I've got a line like this:
> > $str=preg_replace( "-regex here-", '\n\1', $str);
> >
> > Which has one of two problems: If I leave the single quotes around the
> > second argument, then it returns as \n and not a newline. If I change
> > the single quotes to double quotes, then the info from the regex is
> > not inserted in place of the \1.
> >
> > What is one to do in these situations?
> 
> Single quotes have only two (2) special characters:
> ' and \
> 
> You need \' to get a ' buried inside a single quote.
> 
> Since you use \ as the escape character, but you might want \ in the
> string,  you also want to use \\ to get a single \ in your string.
> 
> That's pretty much *IT* for single quotes.
> 
> 
> Double quotes have much for flexibility.
> 
> Embedded variables, special characters like \n \r \t ..., embedded 1-D
> arrays and object dereferences (->) and even (in recent times) an {}
> construct to evaluate an expression and splice it in.
> 
> In PHP, you need \n inside double quotes to get a newline.
> [Okay, there are other ways, but it's the most common way.]
> 
> \n inside of single quotes don't mean squat.
> 
> So, in PHP "\n" is newline.
> 
> I think "\1" just turns into "1" because 1 is not special following "\"...
> But I can't begin to remember *ALL* the characters that are special
> following "\" especially when you start getting into octal/hex
> representations.
> 
> The trick to remember is that if you want "\" in PHP, you need "\\" to get
> a single "\"
> 
> Now, both PHP *and* RegEx use \ as a special character.
> 
> So, not only do you need "\\" in PHP to get a single "\", you *ALSO* may
> need one (or more) \ characters to "feed" into your RegEx.
> 
> In your case:
> "\n...\1" turns into this in PHP internally:
> "[newline]...1"
> 
> Because \1 don't mean squat to PHP either, really.  It just means "1"
> 
> [Unless it means ASCII charcter 1, which I doubt...]
> 
> Anyway, the \ is being used by PHP as an escape character, and you need a
> \ to get down to the RegEx parser.
> 
> "\n...\\1" will do that.
> 
> PHP will see the "\\" and turn it into \ internally.
> 
> The \ gets handed to the RegEx parser, and it "sees":
> [newline]...\1
> for its input string.
> 
> That's what you want.
> 
> Always try to "see" your PHP / RegEx strings in three stages:
> 
> 1. What you type in PHP.
> 2. What PHP stores internally, which is what it hands to RegEx
> 3. What RegEx is going to "parse" #2 into.
> 
> --
> Like Music?
> http://l-i-e.com/artists.htm
> 
> 
> 

Thanks, Richard. I understand now that php doesn't do the regex stuff
itself- it has a module/apple/program called RegEx do the dirty work.
So I have to pay attention to what RegEx will get. Like paying
attention to the source code of html files and not what we see in the
browser.

Thank you for that explanation. I'm just begining to get familiar
enough with php to have the need (and the ability) to understand what
goes on internally.

By the way, I see that you advertise offices on all the planets and
most of the major moons, but when I try to get in contact with the
Uranus branch, I'm told that the nearest operating office is on Earth.
There's 3 planets and over 20 big moons between those planets, why the
gap in coverage?

Dotan Cohen
http://song-lirics.com/sl/index.php
Song Lirics

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] newline and pregreplace

2005-06-30 Thread Richard Lynch
On Fri, June 24, 2005 3:18 pm, Dotan Cohen said:
> I've got a line like this:
> $str=preg_replace( "-regex here-", '\n\1', $str);
>
> Which has one of two problems: If I leave the single quotes around the
> second argument, then it returns as \n and not a newline. If I change
> the single quotes to double quotes, then the info from the regex is
> not inserted in place of the \1.
>
> What is one to do in these situations?

Single quotes have only two (2) special characters:
' and \

You need \' to get a ' buried inside a single quote.

Since you use \ as the escape character, but you might want \ in the
string,  you also want to use \\ to get a single \ in your string.

That's pretty much *IT* for single quotes.


Double quotes have much for flexibility.

Embedded variables, special characters like \n \r \t ..., embedded 1-D
arrays and object dereferences (->) and even (in recent times) an {}
construct to evaluate an expression and splice it in.

In PHP, you need \n inside double quotes to get a newline.
[Okay, there are other ways, but it's the most common way.]

\n inside of single quotes don't mean squat.

So, in PHP "\n" is newline.

I think "\1" just turns into "1" because 1 is not special following "\"...
But I can't begin to remember *ALL* the characters that are special
following "\" especially when you start getting into octal/hex
representations.

The trick to remember is that if you want "\" in PHP, you need "\\" to get
a single "\"

Now, both PHP *and* RegEx use \ as a special character.

So, not only do you need "\\" in PHP to get a single "\", you *ALSO* may
need one (or more) \ characters to "feed" into your RegEx.

In your case:
"\n...\1" turns into this in PHP internally:
"[newline]...1"

Because \1 don't mean squat to PHP either, really.  It just means "1"

[Unless it means ASCII charcter 1, which I doubt...]

Anyway, the \ is being used by PHP as an escape character, and you need a
\ to get down to the RegEx parser.

"\n...\\1" will do that.

PHP will see the "\\" and turn it into \ internally.

The \ gets handed to the RegEx parser, and it "sees":
[newline]...\1
for its input string.

That's what you want.

Always try to "see" your PHP / RegEx strings in three stages:

1. What you type in PHP.
2. What PHP stores internally, which is what it hands to RegEx
3. What RegEx is going to "parse" #2 into.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] newline and pregreplace

2005-06-24 Thread Dotan Cohen
I've got a line like this:
$str=preg_replace( "-regex here-", '\n\1', $str);

Which has one of two problems: If I leave the single quotes around the
second argument, then it returns as \n and not a newline. If I change
the single quotes to double quotes, then the info from the regex is
not inserted in place of the \1.

What is one to do in these situations?

Dotan
http://lyricslist.com/lyrics/artist_albums/273/jackson_michael.php
Michael Jachson Lyrics

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Newline charactes causing problems

2002-12-05 Thread Joshua E Minnie
I am wondering if it has something to do with the way that MySQL is storing
the data.  But I can't seem to find anything that is helping me when I
search on MySQL related strings.

+-+-+
| Joshua Minnie   |Tel:  269.276.9690   |
| [EMAIL PROTECTED]|Fax:  269.342.8750   |
| www.wildwebtech.com +-+
|   |
| Independent Web Consultant / Developer|
+---+
| SYSTEM INFO   |
+---+
| PHP v. 4.2.3 running on Win 2000 / IIS 5  |
| MySQL v. 3.23.49 running on RedHat 7.3/Apache |
+---+

>"John Wards" <[EMAIL PROTECTED]> wrote:
>On Thursday 05 Dec 2002 3:48 pm, Joshua E Minnie wrote:
>> A load of stuff..
>
>I just read the fist few paragraphs and got bored;-)
>
>but
>
>Have you tried doing a str_replace for \n which is new line? just replate
it
>with a blank string
>
>John



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Newline charactes causing problems

2002-12-05 Thread John Wards
On Thursday 05 Dec 2002 3:54 pm, Joshua E Minnie wrote:
> Already tried that.  Doesn't seem to change anything.
>
how about \r 

John

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Newline charactes causing problems

2002-12-05 Thread 1LT John W. Holmes
Or

$notes = preg_replace("/(\r)?\n/"," ",$_POST['notes']);

in case it's the \r that's actually messing you up and not the \n?

---John Holmes...

- Original Message -
From: "John Wards" <[EMAIL PROTECTED]>
To: "Joshua E Minnie" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, December 05, 2002 10:48 AM
Subject: Re: [PHP] Newline charactes causing problems


On Thursday 05 Dec 2002 3:48 pm, Joshua E Minnie wrote:
> A load of stuff..

I just read the fist few paragraphs and got bored;-)

but

Have you tried doing a str_replace for \n which is new line? just replate it
with a blank string

John

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Newline charactes causing problems

2002-12-05 Thread Joshua E Minnie
Already tried that.  Doesn't seem to change anything.

- Original Message -
From: "John Wards" <[EMAIL PROTECTED]>
To: "Joshua E Minnie" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, December 05, 2002 10:48 AM
Subject: Re: [PHP] Newline charactes causing problems


On Thursday 05 Dec 2002 3:48 pm, Joshua E Minnie wrote:
> A load of stuff..

I just read the fist few paragraphs and got bored;-)

but

Have you tried doing a str_replace for \n which is new line? just replate it
with a blank string

John




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Newline charactes causing problems

2002-12-05 Thread John Wards
On Thursday 05 Dec 2002 3:48 pm, Joshua E Minnie wrote:
> A load of stuff..

I just read the fist few paragraphs and got bored;-)

but

Have you tried doing a str_replace for \n which is new line? just replate it 
with a blank string

John

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Newline charactes causing problems

2002-12-05 Thread Joshua E Minnie
Hey all,
I know this has been asked before, and I have tried many of the
solutions that were posted in the mailing archives, and also did some
googling.  But I can't seem to eliminate some new line characters from a
string.  Here is the scenario:

1. A user inputs some text into an form and submits the form.
2. The information gets put into my MySQL db.
3. I retrieve the information from the db and display it.

Now after the user submits the form, I have tried dumping it to the db in a
few different ways.  First of all, I dumped it directly to the db with no
changes, hoping that I could remove the newline characters and other
unwanted markup and tags when retrieving the string.  I also tried dumping
it to the db with after I used some string manipulation function, such as
stripslashes, nl2br, htmlentities, stripcslashes, trim, rtrim, and even
str_replace.  And just to be safe I made sure I double checked to make sure
the newlines were removed on before displaying by using some of the same
functions, but to no avail.  The newlines still seem to be there.

In the db, I have tried various different field types, from text to varchar
to blob, but this hasn't changed anything either.

The reason it is so important that the newline characters be removed is
because they are being used to create a javascript string.  And if the
newline characters are there then, I get an unterminated string error.

Here is the current code for adding the user input to the db:

http://localhost/errors/script.php?f=addNewTask&r=query_failed";);

header("Location: http://localhost/events/task.php?action=add&set=1";);
  } else {
header("Location:
http://localhost/errors/script.php?f=addNewTask&r=db_conn";);
  }
}

?>

$posted is the array $_POST after it is passed to the function.
$_POST['notes'] is where I am having the problem.

Here is the code for displaying the information from the db:

[library file snippit]
'1'";
$result = mysql_query($query);

while($row=mysql_fetch_assoc($result)) {
  $aTasks[$i] =
array($row['due'],$row['title'],stripslashes($row['notes']));
  $i++;
}
if(isset($aTasks)) {
  array_multisort($aTasks,SORT_DESC,SORT_STRING);
  print("");
  print_r($aTasks);
  print("");
  return($aTasks);
}
  } else {
header("Location:
http://localhost/errors/script.php?f=getTasks&r=db_conn";);
  }
}
?>

[displaying page snippit]
 0) {
  echo("\n");
  echo("aTasks = new Array(\n");
  $sTask = "";
  for($i=0;$i<$len;$i++) {
$sTask .= "\"";
if($tasks[$i][0] < getNow() && $tasks[$i][0] != "x") $sTask .= "Past Due!
"; $sTask .= $tasks[$i][2]."\","; } $sTask = substr($sTask,0,(strlen($sTask) - 1)); echo($sTask.");\n"); echo("\n"); } ?> I know that is going into the db with the newlines still in the string. And I am constantly going back to mysqladmin and the newlines are there, no matter what I do. I was hoping someone could shed some light on what could possibly be causing this. +-+-+ | Joshua Minnie |Tel: 269.276.9690 | | [EMAIL PROTECTED]|Fax: 269.342.8750 | | www.wildwebtech.com +-+ | | | Independent Web Consultant / Developer| +---+ | SYSTEM INFO | +---+ | PHP v. 4.2.3 running on Win 2000 / IIS 5 | | MySQL v. 3.23.49 running on RedHat 7.3/Apache | +---+ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] newline in string

2002-10-13 Thread Shawn McKenzie

Thanks everyone.  I'' be breaking the string after the newline so that I can
convert the html to php echos and write them to a file.

-Shawn

"John W. Holmes" <[EMAIL PROTECTED]> wrote in message
000d01c272c1$54d0$7c02a8c0@coconut">news:000d01c272c1$54d0$7c02a8c0@coconut...
> > I have loaded an html file into a string.  How can I search the string
> for
> > newlines/linefeeds? I know they are there, because if I echo the
> string
> > and
> > view source in the browser, some tags are on new lines.
> >
> > Example:
> > 
> >
> > 
> > 
>
> And do what when you find them? If you just want to know if there are
> newlines in the file, then use strstr(). If you want to remove or
> replace them, then use str_replace(). If you want to add in a  where
> some newlines are, then use nl2br().
>
> ---John Holmes...
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] newline in string

2002-10-13 Thread Shawn McKenzie

I have loaded an html file into a string.  How can I search the string for
newlines/linefeeds? I know they are there, because if I echo the string and
view source in the browser, some tags are on new lines.

Example:





TIA
-Shawn



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] newline in string

2002-10-13 Thread Jason Wong

On Sunday 13 October 2002 17:24, Shawn McKenzie wrote:
> I have loaded an html file into a string.  How can I search the string for
> newlines/linefeeds? I know they are there, because if I echo the string and
> view source in the browser, some tags are on new lines.
>
> Example:
> 
>
> 
> 

Search for "\r" and "\n" for linefeeds and newlines respectively. Note you 
must use double-quotes.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
>From the cradle to the coffin underwear comes first.
-- Bertolt Brecht
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] newline in string

2002-10-13 Thread John W. Holmes

> I have loaded an html file into a string.  How can I search the string
for
> newlines/linefeeds? I know they are there, because if I echo the
string
> and
> view source in the browser, some tags are on new lines.
> 
> Example:
> 
> 
> 
> 

And do what when you find them? If you just want to know if there are
newlines in the file, then use strstr(). If you want to remove or
replace them, then use str_replace(). If you want to add in a  where
some newlines are, then use nl2br().

---John Holmes...



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] newline problem

2002-07-24 Thread Justin French

A new line is NOT a  or  in HTML.

Assuming this output is for HTML (browser) purposes, the browser will ignore
newlines.

second linethird line'; // works for HTML
?>
Will print...

this is first line
second line
third line

... to the browser.



If you have a $string with \n's in it, you can convert these to 's
with the function nl2br():

's for HTML output
$string_html = nl2br($string);


// newlines done with hitting return will work in email and txt files
$string = 'this is first line
second line
third line';

// convert \n's to 's for HTML output
$string_html = nl2br($string);

?>


Think about it -- this HTML...


something
something
something


... will output somethingsomethingsomething to the browser, because browsers
ignore newlines, tabs, and other whitespace in text.  On the other hand,
this HTML...


something
something
something


... would achieve three separate lines, so you need to do the same thing
when echoing.


HTH

Justin French


on 25/07/02 2:11 PM, Wormy . ([EMAIL PROTECTED]) wrote:

> Dear all,
> this sounds like a silly problem but i really dunno how to fix it!
> 
> In the php manual on php.net said we can use an embedded newline just
> by writing the string on different line by pressing "enter" key. This
> doesn't work for me. Another thing is \n also work. For example:
> 
>  echo ' You can also have embedded newlines in strings,
> like this way.';
> echo 'I am trying to include at this point: \n a newline';
> ?>
> 
> the output i get is:
> "You can also have embedded newlines in strings, like this way.I am trying
> to include at this point: \n a newline"
> 
> Am I doing anything wrong? Thanks!
> 
> Ser Yee
> 
> _
> Join the world’s largest e-mail service with MSN Hotmail.
> http://www.hotmail.com
> 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] newline problem

2002-07-24 Thread Jason Wong

On Thursday 25 July 2002 12:11, Wormy . wrote:
> Dear all,
>  this sounds like a silly problem but i really dunno how to fix it!
>
>  In the php manual on php.net said we can use an embedded newline just
> by writing the string on different line by pressing "enter" key. This
> doesn't work for me. Another thing is \n also work. For example:
>
>echo ' You can also have embedded newlines in strings,
>   like this way.';
>   echo 'I am trying to include at this point: \n a newline';
> ?>
>
> the output i get is:
> "You can also have embedded newlines in strings, like this way.I am trying
> to include at this point: \n a newline"
>
> Am I doing anything wrong? Thanks!

Stuff like \n are only interpreted if they are enclosed in double-quotes:

"This works\n"
'This does not work\n'

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
Iron Law of Distribution:
Them that has, gets.
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] newline problem

2002-07-24 Thread Wormy .

Dear all,
 this sounds like a silly problem but i really dunno how to fix it!

 In the php manual on php.net said we can use an embedded newline just 
by writing the string on different line by pressing "enter" key. This 
doesn't work for me. Another thing is \n also work. For example:



the output i get is:
"You can also have embedded newlines in strings, like this way.I am trying 
to include at this point: \n a newline"

Am I doing anything wrong? Thanks!

Ser Yee

_
Join the world’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Newline in fputs

2002-05-16 Thread Miguel Cruz

On Thu, 16 May 2002, Henry Grech-Cini wrote:
> header("Content-type: Application/octet-stream");
> 
> The downloaded file does not contain Windows type carriage returns of
> newlines! However it does contains the data thank goodness.

If you want the newlines converted, then you need to use a text data type,
not application/octet-stream. Try text/plain, for instance.

miguel


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Newline in fputs

2002-05-16 Thread Analysis & Solutions

On Thu, May 16, 2002 at 02:14:13PM +0100, Henry Grech-Cini wrote:
> 
> I'm having problems with carriage returns placed in a file on a Linux based
> server. When this file is download to a WindowsXP machine the carriage
> returns are quite frankly useless.

Unix type machines separate lines with a newline char "\n"
Windows type machines separate lines with a return and newline "\r\n"

If you want things to look nice on both, use "\r\n"

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Newline in fputs

2002-05-16 Thread Henry Grech-Cini

Dear All,

Firstly, I am a newbie to php so please be gentle.

I'm having problems with carriage returns placed in a file on a Linux based
server. When this file is download to a WindowsXP machine the carriage
returns are quite frankly useless. I just get "[]" (where "[]" represents an
undisplayable character. No actual carriage returns or newlines!

I generate the file using the following code (fragment only):

 while($row=mysql_fetch_array($mysql_result))
{
  $f_title=$row["title"];
  $f_first_name=$row["first_name"];
  $f_surname=$row["surname"];
  $f_email=$row["email"];
  fputs($file_op,"$f_title, $f_first_name, $f_surname, $f_email\n");
}

I then use the following link to a download_it.php script as described in
Tansley as follows:

$parameters="file_name=".urlencode($file_name)."&file_size=$file_size";
 echo "download it";

The download_it.php file looks as follows:


Appart from the fact that the Content-Disposition appears not to be working
under IE6 since the file name is not correct.

The downloaded file does not contain Windows type carriage returns of
newlines! However it does contains the data thank goodness.

What is the fix?

Henry Grech-Cini



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Newline features and differences between php3 and php4

2002-04-18 Thread Jason Wong

On Friday 19 April 2002 04:58, Richard Archer wrote:

> Note that (IMHO) the manual page for mail() is wrong. I believe the
> line endings used to separate headers should be the system's native
> line endings. Not "\r\n". Using "\r\n" on a Unix box can cause some
> MTA's (qmail, in particular) to imagine *two* line endings, thus ending
> your headers.

The manual is correct. See:

http://cr.yp.to/immhf/header.html

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
The trouble with superheros is what to do between phone booths.
-- Ken Kesey
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Newline features and differences between php3 andphp4

2002-04-18 Thread Richard Archer

At 8:24 AM -0700 18/4/02, Chris Hall wrote:

>I'm using the mail() function on a project for a client. His hosting
>provider currently offers php3, meanwhile I've been developing in php4. So
>far, I don't haven't found any problems other than the following:
>In php4, inside the mail function I use newline definitions to seperate
>data, and it works terrific. But in php3 mail() doesn't seem to parse the
>newline tags, and it prints them in the email body. Workarounds/fixes?

Sounds to me as if you have an extra newline in there. The first blank
line indicates to the MTA/MUA the end of the headers and the start of
the message body.

Note that (IMHO) the manual page for mail() is wrong. I believe the
line endings used to separate headers should be the system's native
line endings. Not "\r\n". Using "\r\n" on a Unix box can cause some
MTA's (qmail, in particular) to imagine *two* line endings, thus ending
your headers.

 ...R.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Newline features and differences between php3 and php4

2002-04-18 Thread Miguel Cruz

On Thu, 18 Apr 2002, Chris Hall wrote:
> I'm using the mail() function on a project for a client. His hosting
> provider currently offers php3, meanwhile I've been developing in php4. So
> far, I don't haven't found any problems other than the following:
> In php4, inside the mail function I use newline definitions to seperate
> data, and it works terrific. But in php3 mail() doesn't seem to parse the
> newline tags, and it prints them in the email body. Workarounds/fixes?

I don't think that's really what's happening. The newline tags (\n) are 
interpreted when the string is parsed, long before anything makes it to 
the mail() function.

Do you have a brief but relevant code snippet?

miguel


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Newline features and differences between php3 and php4

2002-04-18 Thread Chris Hall

Morning all,
I'm using the mail() function on a project for a client. His hosting
provider currently offers php3, meanwhile I've been developing in php4. So
far, I don't haven't found any problems other than the following:
In php4, inside the mail function I use newline definitions to seperate
data, and it works terrific. But in php3 mail() doesn't seem to parse the
newline tags, and it prints them in the email body. Workarounds/fixes?

Thanks in advance.

--
Chris Hall
hardwired industries



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Newline in a guestbook

2001-04-24 Thread Plutarck

You can also use the strlen() function.


--
Plutarck
Should be working on something...
...but forgot what it was.


"Jimmy Bäckström" <[EMAIL PROTECTED]> wrote in message
000a01c0cd06$351f1060$[EMAIL PROTECTED]">news:000a01c0cd06$351f1060$[EMAIL PROTECTED]...
Hey guys!
I'm writing a guestbook with mysql. My probblem is that when user enter at
long word like blablablablablablablablablablablabla my html-tables gets
screwed up. If someone is just fooling around the whole page design can be
destroyed. I want to know how I can make sure that no word is longer than x
characters. If a word should be longer than that, I would like the word
divided into smaller parts with a - character at the end of the first word
like this:

"this is a text in the guestbook.
if there is a really long word
like blablablablablablablabla-
blablabla it is divided into
smaller parts and a - char
is added to the first word."

I thought about reading the whole message into an array, and then loop
through it and for each word check whether it is larger than x chars, and if
so, change it. But couldn't that be a very memory consuming script if it
should do that for every message? Anyone knows how I could do this?




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Newline in a guestbook

2001-04-24 Thread Henrik Hansen

Jimmy Bäckström <[EMAIL PROTECTED]> wrote:

 > I thought about reading the whole message into an array, and then loop through it 
 >and for each word check whether it is larger than x chars, and if so, change it. But 
 >couldn't that be a very memory consuming script if it should do that for every 
 >message? Anyone knows how I could do this?

Dont! look at the wordwrap function, in short in works like this:

echo wordwrap ($body, $length, "");

read more here:

http://www.php.net/manual/en/function.wordwrap.php

-- 
Henrik Hansen


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Newline in a guestbook

2001-04-24 Thread Jimmy Bäckström

Hey guys!
I'm writing a guestbook with mysql. My probblem is that when user enter at long word 
like blablablablablablablablablablablabla my html-tables gets screwed up. If someone 
is just fooling around the whole page design can be destroyed. I want to know how I 
can make sure that no word is longer than x characters. If a word should be longer 
than that, I would like the word divided into smaller parts with a - character at the 
end of the first word like this:

"this is a text in the guestbook.
if there is a really long word
like blablablablablablablabla-
blablabla it is divided into
smaller parts and a - char
is added to the first word."

I thought about reading the whole message into an array, and then loop through it and 
for each word check whether it is larger than x chars, and if so, change it. But 
couldn't that be a very memory consuming script if it should do that for every 
message? Anyone knows how I could do this?



Re: [PHP] newline in preg_split

2001-03-18 Thread Ville Mattila

Hello,

If you read the file with file()-function, you can get as a result an array which 
includes each row of the file.

For example:
$rows = file("c:\thisfile.txt");

echo $rows[0];
echo $rows[1];
echo $rows[2];

The result should be now like following:
core 010105
business 070344
core 020202

Note that also \n and \r -characters are included to the array.

Cheers,
- Ville


- Original Message - 
From: Jesper Blomström <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, March 19, 2001 12:31 AM
Subject: [PHP] newline in preg_split


> Hi!
> 
> I have text file looking something like this:
> 
> core 010105
> business 070344
> core 020202
> ...
> 
> 
> The textfile is a result from a database question and I am trying to parse
> the file in order to retrieve each line. I have tried using the
> explode()-method but I can´t get it to work with the delimiter \n (or \r or
> \\n...).
> I have also tried to use the preg_split()-method which takes a RE-argument
> but that doesn´t seem to work either (have tried in a lot of ways).
> 
> Can anyone give me a clue how to solve this problem?
> 
> Many thanks from Stockholm, Sweden!
> 
> Jesper Blomstroem
> 
> 
> 
> --
> 
> Jesper Blomström
> 08-370 317 (Hem)
> 08-566 280 08 (Arbete)
> 070-3024911
> 
> Ångermannagatan 113
> 162 64 Vällingby
> 
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] newline in preg_split

2001-03-18 Thread Jesper Blomström

Hi!

I have text file looking something like this:

core 010105
business 070344
core 020202
...


The textfile is a result from a database question and I am trying to parse
the file in order to retrieve each line. I have tried using the
explode()-method but I can´t get it to work with the delimiter \n (or \r or
\\n...).
I have also tried to use the preg_split()-method which takes a RE-argument
but that doesn´t seem to work either (have tried in a lot of ways).

Can anyone give me a clue how to solve this problem?

Many thanks from Stockholm, Sweden!

Jesper Blomstroem



--

Jesper Blomström
08-370 317 (Hem)
08-566 280 08 (Arbete)
070-3024911

Ångermannagatan 113
162 64 Vällingby





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] newline processing problem?

2001-02-11 Thread Ankur Verma

try using "\r\n" instead of a simple "\n".

hope that helps

Ankur Verma
HCL Technologies
A1CD, Sec -16
Noida, UP
India

- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, February 11, 2001 6:51 AM
Subject: [PHP] newline processing problem?


>
> I have some code which generates a large string to be used by the mail()
> function.  At the same point in the string each time, PHP stops processing
> "\n" correctly and instead of a newline outputs nothing, so the text
starts to
> get run together.. but it doesn't seem to happen on every "\n".  Has
anyone
> else run into this problem?  It used to work correctly but I made a few
> changes to portions of the code that were totally uninvolved, and it
started
> behaving this way.  Unfortunately, I didn't notice the problem until I'd
made
> a number of small changes to unrelated things and didn't remember what
they
> were.
>
>
>
> Gordon Morehouse
> [EMAIL PROTECTED]
> www.evernex.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] newline processing problem?

2001-02-11 Thread Richard Lynch

> I have some code which generates a large string to be used by the mail()
> function.  At the same point in the string each time, PHP stops processing
> "\n" correctly and instead of a newline outputs nothing, so the text
starts to
> get run together.. but it doesn't seem to happen on every "\n".  Has
anyone
> else run into this problem?  It used to work correctly but I made a few
> changes to portions of the code that were totally uninvolved, and it
started
> behaving this way.  Unfortunately, I didn't notice the problem until I'd
made
> a number of small changes to unrelated things and didn't remember what
they
> were.

To really be RFC-compliant, you should use "\r\n" instead of just "\n" --
Un*x mail-handling mostly fixes it for you, but...

My guess would be that you lost a \n somewhere or that you have \\n
somewhere...

--
Visit the Zend Store at http://www.zend.com/store/
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] newline processing problem?

2001-02-10 Thread nphyre


I have some code which generates a large string to be used by the mail() 
function.  At the same point in the string each time, PHP stops processing 
"\n" correctly and instead of a newline outputs nothing, so the text starts to 
get run together.. but it doesn't seem to happen on every "\n".  Has anyone 
else run into this problem?  It used to work correctly but I made a few 
changes to portions of the code that were totally uninvolved, and it started 
behaving this way.  Unfortunately, I didn't notice the problem until I'd made 
a number of small changes to unrelated things and didn't remember what they 
were.



Gordon Morehouse
[EMAIL PROTECTED]
www.evernex.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]