|
![]() |
![]() |
![]() |
![]() |
![]() |
|
|
|
|
#1 | |
|
Shift Out / X-On
|
i'm stuck in counting new lines PHP
So I have a $ckeys['keywords'] string, (extract from head meta keywords ) that pretty much looks like this:
word word word word and so on, depends how many keywords there is. Now I wrapped every new line into a separate <p> paragraph. Quote:
Anyone ? ![]() |
|
|
|
|
|
|
#2 |
|
a.k.a. Sparky
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
|
Code:
<?php
$ckeys['keywords'] = array('word1','word2','word3','word4');
$loop = 1;
foreach ($ckeys['keywords'] as $word) {
printf("<p id='cell%d'>%s</p>\n", $loop, $word);
$loop++;
}
__________________
SnapReplay.com a different way to share photos - iPhone & Android |
|
|
|
|
|
#3 |
|
Are you sure you're an accredited and honored pornographer?
Join Date: Sep 2008
Posts: 67
|
I think sparky's answer is good but addresses a slightly different question. Perhaps this is closer to the question as posed:
Code:
<?php
$ckeys = array();
$ckeys['keywords'] = <<<EOT
word1
word2
word3
word4
EOT;
foreach (explode("\n", $ckeys['keywords']) as $i => $w) {
$id = "cell" . ($i+1);
echo "<p id='$id'>$w</p>\n";
}
?>
|
|
|
|
|
|
#4 |
|
a.k.a. Sparky
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
|
You are correct, I assumed that the words were actually in his keywords array.
__________________
SnapReplay.com a different way to share photos - iPhone & Android |
|
|
|
|
|
#5 |
|
Shift Out / X-On
|
thank you guys
I'll test this tonight. Last edited by pc; 2012-04-19 at 03:05 PM.. |
|
|
|
|
|
#6 |
|
Shift Out / X-On
|
I already had keywords in array. But it works. Both cd34 and flowersgone without array works. Thanks again.
|
|
|
|
![]() |
|
|