Re: count newlines in heredoc variable
- From: Adam Cantrell <cantrell78@xxxxxxxxx>
- Date: Wed, 30 Jul 2008 11:54:00 -0700 (PDT)
Thank you very much -
Adam Cantrell
On Jul 30, 11:48 am, petersprc <peters...@xxxxxxxxx> wrote:
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');
?>
.
- References:
- count newlines in heredoc variable
- From: Adam Cantrell
- Re: count newlines in heredoc variable
- From: petersprc
- count newlines in heredoc variable
- Prev by Date: Re: count newlines in heredoc variable
- Next by Date: Re: <? view_content(78) ?>
- Previous by thread: Re: count newlines in heredoc variable
- Next by thread: if statement in an elseif block with a preceeding exit statement
- Index(es):
Relevant Pages
|