Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8939119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:45:48+00:00 2026-06-15T10:45:48+00:00

haha, I still have the problem of keywords, but this is a code that

  • 0

haha, I still have the problem of keywords, but this is a code that I’m creating.

Is a poor code but is my creation:

<?php
$url = 'http://es.wikipedia.org/wiki/Animalia';
Keys($url);
function Keys($url) { 
$listanegra = array("a", "ante", "bajo", "con", "contra", "de", "desde", "mediante", "durante", "hasta", "hacia", "para", "por", "que", "qué", "cuán", "cuan", "los", "las", "una", "unos", "unas", "donde", "dónde", "como", "cómo", "cuando", "porque", "por", "para", "según", "sin", "tras", "con", "mas", "más", "pero", "del"); 

    $doc = new DOMDocument();
    libxml_use_internal_errors(true);
    $doc->loadHTMLFile($url);
    $webhtml = $doc->getElementsByTagName('p');
    $webhtml = $webhtml ->item(0)->nodeValue;

    $webhtml = strip_tags($webhtml);
    $webhtml = explode(" ", $webhtml);

    foreach($listanegra as $key=> $ln) {
    $webhtml = str_replace($ln, " ", $webhtml);
    }
    $palabras = str_word_count ("$webhtml", 1 ); 
    $frq = array_count_values ($palabras); 
    $frq = asort($frq);
    $ffrq = count($frq);
$i=1;
while ($i < $ffrq) {
    print $frqq[$i];
    print '<br />';
    $i++;
}
}
?>

The code trying extract keywords of a website. Extracts the first paragraph of a web, and deletes the words of the variable “$listanegra”. Next, counts the repeat words and saves all words in a “array”. After i call the array, and this show me the words.

The problem is… the code it’s not functional =(.

When i use the code, this shows blank.

Could help me finish my code?. Was recommending me to using “tf-idf”, but I will use it later.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:45:48+00:00Added an answer on June 15, 2026 at 10:45 am

    I do believe this is what you were trying to do:

    $url = 'http://es.wikipedia.org/wiki/Animalia';
    
    $words = Keys($url);
    
    /// do your database stuff with $words
    
    
    function Keys($url)
    {
        $listanegra = array('a', 'ante', 'bajo', 'con', 'contra', 'de', 'desde', 'mediante', 'durante', 'hasta', 'hacia', 'para', 'por', 'que', 'qué', 'cuán', 'cuan', 'los', 'las', 'una', 'unos', 'unas', 'donde', 'dónde', 'como', 'cómo', 'cuando', 'porque', 'por', 'para', 'según', 'sin', 'tras', 'con', 'mas', 'más', 'pero', 'del');
    
        $doc = new DOMDocument();
        libxml_use_internal_errors(true);
        $doc->loadHTMLFile($url);
        $webhtml = $doc->getElementsByTagName('p');
        $webhtml = $webhtml->item(0)->nodeValue;
        $webhtml = strip_tags($webhtml);
        $webhtml = explode(' ', $webhtml);
    
        $palabras = array();
        foreach($webhtml as $word)
        {
            $word = strtolower(trim($word, ' .,!?()')); // remove trailing special chars and spaces
            if (!in_array($word, $listanegra))
            {
                $palabras[] = $word;
            }
        }
        $frq = array_count_values($palabras);
        asort($frq);
        return implode(' ', array_keys($frq));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The code is working in that it couts haha but it causes an error
So I'm trying out this new TDD thing (about time haha). Anyways I have
(This is my first try with php) I have a very basic register page.
i have this json returned from my ajax call [ {message:haha, type:error}, {message:nice work,
I have searched all over the Google and StackOverFlow, but still did not find
I have an onbeforeunload event : $().ready(function() { window.onbeforeunload=function() { return haha }; });
I'm trying to write someting into the DB using PHP but if I try
c code extern C __declspec(dllexport) int export(LPCTSTR inputFile, string &msg) { msg = haha
I have server and client to send/receive a string through windows sockets. Client code
Simple question I believe for anyone with minimal php skills (which I don't have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.