php-general Digest 19 Aug 2012 19:52:54 -0000 Issue 7929
Topics (messages 318752 through 318758):
Re: Cost of redirect and site domain switch? Good Practice / Bad Practice /
Terrible Practice
318752 by: Daniel Brown
318753 by: Paul M Foster
How do I do count the occurrence of each word?
318754 by: John Taylor-Johnston
318755 by: tamouse mailing lists
318756 by: Marco Behnke
318757 by: tamouse mailing lists
OT (maybe not): Drupal vs WordPress
318758 by: lamp.afan.net
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On Aug 18, 2012 4:49 PM, "Paul M Foster" <pa...@quillandmouse.com> wrote:
>
> I can comment on part of this based on what I was recently told by an
> SEO company. Let's assume you've got a bunch of SEO "goodness"
> (recognition, Google search placement, etc.) going for you on site1.com.
> If you a permanent redirect (301) to site2.com, all that SEO goodness
> will transfer straight across to the new site.
>
> You may take this with whatever grain of salt you like, considering it
> comes from an SEO company and I consider SEO companies almost uniformly
> liars and ripoff artists who generally have no earthly idea what they're
> talking about. In this case, what they're saying makes sense to me, and
> I suspect it's true.
That doesn't sound right to me. If so, I'd presume a lot of folks
would be doing that as a service. I have several PR6-8 domains myself, and
could see how someone (not me) might say, "since I'm really not using these
domains anyway, I'll 301 to a paying customer for them to include their
ranking." If for no other reason than I haven't heard of folks doing this
(read: SPAM), I'd guess it's not true.
Still, other folks are far more knowledgeable than Yours Truly when it
comes to SEO. Just for good measure, I've CC'd one (Thiago Pojda) to see
if he'd be interested in chiming in on the matter.
--- End Message ---
--- Begin Message ---
On Sat, Aug 18, 2012 at 05:10:39PM -0400, Daniel Brown wrote:
> On Aug 18, 2012 4:49 PM, "Paul M Foster" <[1]pa...@quillandmouse.com>
> wrote:
> >
> > I can comment on part of this based on what I was recently told by an
> > SEO company. Let's assume you've got a bunch of SEO "goodness"
> > (recognition, Google search placement, etc.) going for you on
> [2]site1.com.
> > If you a permanent redirect (301) to [3]site2.com, all that SEO goodness
> > will transfer straight across to the new site.
> >
> > You may take this with whatever grain of salt you like, considering it
> > comes from an SEO company and I consider SEO companies almost uniformly
> > liars and ripoff artists who generally have no earthly idea what they're
> > talking about. In this case, what they're saying makes sense to me, and
> > I suspect it's true.
>
> ��� That doesn't sound right to me.� If so, I'd presume a lot of folks
> would be doing that as a service.� I have several PR6-8 domains myself,
> and could see how someone (not me) might say, "since I'm really not using
> these domains anyway, I'll 301 to a paying customer for them to include
> their ranking."� If for no other reason than I haven't heard of folks
> doing this (read: SPAM), I'd guess it's not true.
>
> ��� Still, other folks are far more knowledgeable than Yours Truly when it
> comes to SEO.� Just for good measure, I've CC'd one (Thiago Pojda) to see
> if he'd be interested in chiming in on the matter.
[grin]
Well, what I didn't say in my original email was why this came up with
the SEO company in the first place (and part of why I think SEO
companies have no idea what they're talking about).
We had built a website for a customer, and then they called in this SEO
company to advise them. The SEO company insisted on a 301 permanent
redirect at the top of every page of the site. From what domain to what
domain, you may ask. From www.yourdomain.com to yourdomain.com. I kid
you not. The theory being that the SEO "goodness" from
www.yourdomain.com would transfer to yourdomain.com, if someone came in
from a www.yourdomain.com link somewhere. Seriously. Never mind that for
years, DNS zone files have been routinely set up so that www.example.com
is a DNS alias for example.com, and so it was in this case as well.
Besides which, does anyone imagine that the spiders and evaluation
engines for bright companies like Google and Yahoo might actually think
that www.example.com and example.com have completely different content?
I can also say that, on some of these pages we built, there were forms
which emailed the surfer's responses to someone at our customer's
company. And the extraneous 301s at the top of these form pages
apparently interfered with the functionality of these pages. When the
301s were removed, we ceased to have complaints from our customer
regarding the forms.
Like I said, take it with whatever grain of salt you like. And if
someone more knowledgeable than the rest of us says otherwise, take
their word for it instead.
Paul
--
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com
--- End Message ---
--- Begin Message ---
I want to parse this text and count the occurrence of each word:
$text =
http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html; #Can I
do this?
$stripping = strip_tags($text); #get rid of html
$stripping = strtolower($stripping); #put in lowercase
----------------
First of all I want to start AFTER the expression "News Releases" and
stop BEFORE the next occurrence of "-30-"
#This may occur an undetermined number of times on
http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html
----------------
Second, do I put $stripping into an array to separate each word by each
space " "?
$stripping = implode(" ", $stripping);
----------------
Third how do I count the number of occurrences of each word?
Sample Output:
determined = 4
fire = 7
patrol = 3
theft = 6
witness = 1
witnessed = 1
----------------
<?php
$text = http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html
#echo strip_tags($text);
#echo "\n";
$stripping = strip_tags($text);
#Get text between "News Releases" and stop before the next occurrence of
"-30-"
#$stripping = str_replace("\r", " ", $stripping);# getting rid of \r
#$stripping = str_replace("\n", " ", $stripping);# getting rid of \n
#$stripping = str_replace(" ", " ", $stripping);# getting rid of the
occurrences of double spaces
#$stripping = strtolower($stripping);
#Where do I go now?
?>
--- End Message ---
--- Begin Message ---
On Sat, Aug 18, 2012 at 6:44 PM, John Taylor-Johnston
<jt.johns...@usherbrooke.ca> wrote:
> I want to parse this text and count the occurrence of each word:
>
> $text = http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html;
> #Can I do this?
> $stripping = strip_tags($text); #get rid of html
> $stripping = strtolower($stripping); #put in lowercase
>
> ----------------
> First of all I want to start AFTER the expression "News Releases" and stop
> BEFORE the next occurrence of "-30-"
>
> #This may occur an undetermined number of times on
> http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html
>
>
> ----------------
> Second, do I put $stripping into an array to separate each word by each
> space " "?
>
> $stripping = implode(" ", $stripping);
>
> ----------------
> Third how do I count the number of occurrences of each word?
>
> Sample Output:
>
> determined = 4
> fire = 7
> patrol = 3
> theft = 6
> witness = 1
> witnessed = 1
>
> ----------------
> <?php
> $text = http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html
> #echo strip_tags($text);
> #echo "\n";
> $stripping = strip_tags($text);
>
> #Get text between "News Releases" and stop before the next occurrence of
> "-30-"
>
> #$stripping = str_replace("\r", " ", $stripping);# getting rid of \r
> #$stripping = str_replace("\n", " ", $stripping);# getting rid of \n
> #$stripping = str_replace(" ", " ", $stripping);# getting rid of the
> occurrences of double spaces
>
> #$stripping = strtolower($stripping);
>
> #Where do I go now?
> ?>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
This is usually a first-year CS programming problem (word frequency
counts) complicated a little bit by needing to extract the text.
You've started off fine, stripping tags, converting to lower case,
you'll want to either convert or strip HTML entities as well, deciding
what you want to do with plurals and words like "you're", "Charlie's",
"it's", etc, also whether something like RFC822 is a word or not
(mixed letters and numbers).
When you've arranged all that, splitting on white space is trivial:
$words = preg_split('/[[:space:]]+/',$text);
and then you just run through the words building an associative array
by incrementing the count of each word as the key to the array:
foreach ($words as $word) {
$freq[$word]++;
}
For output, you may want to sort the array:
ksort($freq);
--- End Message ---
--- Begin Message ---
Am 19.08.12 06:59, schrieb tamouse mailing lists:
> On Sat, Aug 18, 2012 at 6:44 PM, John Taylor-Johnston
> <jt.johns...@usherbrooke.ca> wrote:
>> I want to parse this text and count the occurrence of each word:
>>
>> $text = http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html;
>> #Can I do this?
>> $stripping = strip_tags($text); #get rid of html
>> $stripping = strtolower($stripping); #put in lowercase
>>
>> ----------------
>> First of all I want to start AFTER the expression "News Releases" and stop
>> BEFORE the next occurrence of "-30-"
>>
>> #This may occur an undetermined number of times on
>> http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html
>>
>>
>> ----------------
>> Second, do I put $stripping into an array to separate each word by each
>> space " "?
>>
>> $stripping = implode(" ", $stripping);
>>
>> ----------------
>> Third how do I count the number of occurrences of each word?
>>
>> Sample Output:
>>
>> determined = 4
>> fire = 7
>> patrol = 3
>> theft = 6
>> witness = 1
>> witnessed = 1
>>
>> ----------------
>> <?php
>> $text = http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html
>> #echo strip_tags($text);
>> #echo "\n";
>> $stripping = strip_tags($text);
>>
>> #Get text between "News Releases" and stop before the next occurrence of
>> "-30-"
>>
>> #$stripping = str_replace("\r", " ", $stripping);# getting rid of \r
>> #$stripping = str_replace("\n", " ", $stripping);# getting rid of \n
>> #$stripping = str_replace(" ", " ", $stripping);# getting rid of the
>> occurrences of double spaces
>>
>> #$stripping = strtolower($stripping);
>>
>> #Where do I go now?
>> ?>
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
> This is usually a first-year CS programming problem (word frequency
> counts) complicated a little bit by needing to extract the text.
> You've started off fine, stripping tags, converting to lower case,
> you'll want to either convert or strip HTML entities as well, deciding
> what you want to do with plurals and words like "you're", "Charlie's",
> "it's", etc, also whether something like RFC822 is a word or not
> (mixed letters and numbers).
>
> When you've arranged all that, splitting on white space is trivial:
>
> $words = preg_split('/[[:space:]]+/',$text);
>
> and then you just run through the words building an associative array
> by incrementing the count of each word as the key to the array:
>
> foreach ($words as $word) {
> $freq[$word]++;
> }
Please an existence check to avoid incrementing not set array keys
foreach ($words as $word) {
if (array_key_exists($word, $freq)) {
$freq[$word] = 1;
} else {
$freq[$word]++;
}
}
>
> For output, you may want to sort the array:
>
> ksort($freq);
>
--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3
Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz
Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal
http://www.behnke.biz
signature.asc
Description: OpenPGP digital signature
--- End Message ---
--- Begin Message ---
On Sun, Aug 19, 2012 at 12:38 AM, Marco Behnke <ma...@behnke.biz> wrote:
> Am 19.08.12 06:59, schrieb tamouse mailing lists:
>> On Sat, Aug 18, 2012 at 6:44 PM, John Taylor-Johnston
>> <jt.johns...@usherbrooke.ca> wrote:
>>> I want to parse this text and count the occurrence of each word:
>>>
>>> $text = http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html;
>>> #Can I do this?
>>> $stripping = strip_tags($text); #get rid of html
>>> $stripping = strtolower($stripping); #put in lowercase
>>>
>>> ----------------
>>> First of all I want to start AFTER the expression "News Releases" and stop
>>> BEFORE the next occurrence of "-30-"
>>>
>>> #This may occur an undetermined number of times on
>>> http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html
>>>
>>>
>>> ----------------
>>> Second, do I put $stripping into an array to separate each word by each
>>> space " "?
>>>
>>> $stripping = implode(" ", $stripping);
>>>
>>> ----------------
>>> Third how do I count the number of occurrences of each word?
>>>
>>> Sample Output:
>>>
>>> determined = 4
>>> fire = 7
>>> patrol = 3
>>> theft = 6
>>> witness = 1
>>> witnessed = 1
>>>
>>> ----------------
>>> <?php
>>> $text = http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html
>>> #echo strip_tags($text);
>>> #echo "\n";
>>> $stripping = strip_tags($text);
>>>
>>> #Get text between "News Releases" and stop before the next occurrence of
>>> "-30-"
>>>
>>> #$stripping = str_replace("\r", " ", $stripping);# getting rid of \r
>>> #$stripping = str_replace("\n", " ", $stripping);# getting rid of \n
>>> #$stripping = str_replace(" ", " ", $stripping);# getting rid of the
>>> occurrences of double spaces
>>>
>>> #$stripping = strtolower($stripping);
>>>
>>> #Where do I go now?
>>> ?>
>>>
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>> This is usually a first-year CS programming problem (word frequency
>> counts) complicated a little bit by needing to extract the text.
>> You've started off fine, stripping tags, converting to lower case,
>> you'll want to either convert or strip HTML entities as well, deciding
>> what you want to do with plurals and words like "you're", "Charlie's",
>> "it's", etc, also whether something like RFC822 is a word or not
>> (mixed letters and numbers).
>>
>> When you've arranged all that, splitting on white space is trivial:
>>
>> $words = preg_split('/[[:space:]]+/',$text);
>>
>> and then you just run through the words building an associative array
>> by incrementing the count of each word as the key to the array:
>>
>> foreach ($words as $word) {
>> $freq[$word]++;
>> }
>
> Please an existence check to avoid incrementing not set array keys
>
> foreach ($words as $word) {
> if (array_key_exists($word, $freq)) {
> $freq[$word] = 1;
> } else {
> $freq[$word]++;
> }
> }
Ah, yes, good point -- as written, my code will raise two notices. In
addition, "declare" the $freq array:
$freq=array();
as well before the foreach loop to ensure notice-free operation.
>
>
>>
>> For output, you may want to sort the array:
>>
>> ksort($freq);
>>
>
>
> --
> Marco Behnke
> Dipl. Informatiker (FH), SAE Audio Engineer Diploma
> Zend Certified Engineer PHP 5.3
>
> Tel.: 0174 / 9722336
> e-Mail: ma...@behnke.biz
>
> Softwaretechnik Behnke
> Heinrich-Heine-Str. 7D
> 21218 Seevetal
>
> http://www.behnke.biz
>
>
--- End Message ---
--- Begin Message ---
Hi to everyone,
I was trying to figure this out for the last week or two. I have read tons
of articles that compare Drupal and WordPress, but I still wasn't swayed
to either side.
I know that they are both good, both do the job well, and both have
advantages and disadvantages. For example, Drupal has a steeper learning
curve, but you get more control over the website.
Most of Drupal vs WordPress articles are "emotionally" driven and it
reminds me of the PC vs Apple flame war. I was trying to exclude these as
much as I could but it's hard.
Is there any website/article/benchmark/test/experiment/whatever I can
trust to be unbiased? I need a website that measures the CMS' through
facts, not heated, emotional arguments. In which cases is it better to use
Drupal over WordPress (and vice-versa)? I know the first two words are
going to be "it depends", but let's talk about it in general (for small
basic websites, more complex websites, easy customization, etc).
I found this on one page: "... Drupal was built as a fine-grained
multi-role system where you can assign different permissions to different
roles to do different things (e.g. content editor, content reviewer,
member, etc.) and assign users to these roles..." Does that mean that
WordPress can't do that? Maybe it can, and the quotation is true, but it
is kind of misleading to say that one of the programs does something, and
then not mention the other product at all.
Special points for me are (not a must, though)
- multiple websites with single core (both CMSs have the capability but I
got impression Drupal does it better?) because of maintenance
- compatibility with CiviCRM
Once I decide what to use, I have to stick with it for a while.
Thanks for any help.
LAMP
--- End Message ---