You are here: Re: Counting how many times a word appears in a var? « PHP Programming Language « IT news, forums, messages
Re: Counting how many times a word appears in a var?

Posted by Erwin Moller on 10/26/06 13:53

Tyrone Slothrop wrote:

> On 26 Oct 2006 02:41:00 -0700, "Advo" <max_mischief@hotmail.com>
> wrote:
>
>>I've made a small search function as of here:
>>
>>if (stristr($bleh,$search_for)) {
>>if(preg_match('/<title>([^<]*)<\/title>/i', $bleh, $matches))
>>{
>>$name = str_replace("./","/",$name);
>>echo "<li><a href=$link".$name.">".$matches[1]."</a><br><br>";
>>
>>}
>>
>>
>>Now this actually works fine, and gives me a page link and title of a
>>page, based on pages that contain the search term.
>>
>>Im now trying to rationalise the code a bit more, so that the order of
>>the links depends on how many times that certain word appears on the
>>page.
>>
>>Any ideas please?
>>
>>My understanding is that i need to somehow count how many times the
>>$search_for text appears in the $bleh text, and then move onto the next
>>page.
>
> http://us2.php.net/manual/en/function.substr-count.php

Oh Tyrone, that guy is having a great time with regex, and now you spoiled
all the fun with an easy ready-to-go built-in function. :P

Erwin

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация