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 4050548
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:05:01+00:00 2026-05-20T14:05:01+00:00

i am using PHP scripts to implement this… $keyword=array(‘local news’,’art’,’local’,’world’,’tech’,’entertainment’,’news’,’tech’,’top stories’,’in the news’,’front page’,’bbc

  • 0

i am using PHP scripts to implement this…

    $keyword=array('local news','art','local','world','tech','entertainment','news','tech','top stories','in the news','front page','bbc news','week in a glance','week in pictures','top stories');

   //$keyword has predefined array of strings

    $all_meta_tags=get_meta_tags("http://abcnews.go.com/"); 
    $array=$all_meta_tags['keywords'];//store 'keyword' attribute values in $keyword_meta

Now i have to match contents of $array with $keyword…..the results should give me matched items of $array which are present in $keyword

any help plz…?

can array matching/intersection be done case insensitively??
i mean if
$keyword=array(‘local news’);
$array = ‘Local News, International News’;
var_dump(array_intersect(preg_split(‘/,\s*/’, $array), $keyword));

then it won’t match ‘Local News’…can you tel me hw to do it if it is possible??

  • 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-05-20T14:05:02+00:00Added an answer on May 20, 2026 at 2:05 pm
    $inBoth = array_intersect(preg_split('/,\s*/', $array), $keyword);
    

    CodePad.

    get_meta_tags() just returns the keywords as a string, so we need to split it into an array. We take into account people adding spaces, newlines or tabs after the ,.

    You could also skip the regex, and explode on , and then use array_map('trim', $array).

    Without doing this, you run the risk of "art" and " art" not matching.

    Update

    can array matching be done case insensitively?

    If you don’t mind the resulting arrays being lowercase, you could use array_map('strtolower', $array) on both arrays before using array_intersect().

    Otherwise, this will do it…

    $metaKeywords = preg_split('/,\s*/', $array);
    $matches = array();
    foreach($keyword as $keyword) {
      foreach($metaKeywords as $value) {
         if (strtolower($value) == strtolower($keyword)) {
            $matches[] = $keyword;
         }
      }
    }
    

    $matches will have keywords in both arrays case insensitively.

    If you have multibyte strings, use mb_strtolower() or equivalent.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using PHP, and MySql, I am trying to implement this rather snazzy in-place editor
I have two PHP scripts, both using the same session by calling session_name('MySessID') .
I'm using Zend Studio to do remote debugging of my php scripts on a
Using PHP, what's the fastest way to convert a string like this: 123 to
I am using PHP to implement an HTML form and for validation of the
I am using this zoom image script to load thumbs into larger images: http://www.eyecon.ro/zoomimage/#implement
A client is using PHP to connect to MySQL. The PHP scripts and the
I have a simple php script on a server that's using fsockopen to connect
I am using Delphi 7 and ICS components to communicate with php script and
I'm using jQuery to post a form to a php file, simple script to

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.