Re: count newlines in heredoc variable
- From: petersprc <petersprc@xxxxxxxxx>
- Date: Wed, 30 Jul 2008 11:48:02 -0700 (PDT)
Hi,
You're correct, but you just need double quotes: "\n".
In a single-quoted string, the only interpreted escape sequences are \
\ and \'.
Regards,
John Peters
On Jul 30, 2:21 pm, Adam Cantrell <cantrel...@xxxxxxxxx> wrote:
How could I count the number of newlines in a heredoc variable? This
outputs 0, but I thought heredoc preserved newlines?
<?
$test = <<<END
<a href="test5.php">adam</a>
<p>
Hi There
</p>
END;
echo substr_count($test, '\n');
?>
.
- Follow-Ups:
- Re: count newlines in heredoc variable
- From: Adam Cantrell
- Re: count newlines in heredoc variable
- References:
- count newlines in heredoc variable
- From: Adam Cantrell
- count newlines in heredoc variable
- Prev by Date: count newlines in heredoc variable
- Next by Date: Re: count newlines in heredoc variable
- Previous by thread: count newlines in heredoc variable
- Next by thread: Re: count newlines in heredoc variable
- Index(es):
Relevant Pages
|