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

  • Home
  • SEARCH
  • 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 6868221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:24:26+00:00 2026-05-27T03:24:26+00:00

This is my array output Array ( [0] => Array ( [tweet_text] => Fedora

  • 0

This is my array output

Array
(
    [0] => Array
        (
            [tweet_text] => Fedora 16 "Verne" released! http://t.co/lECbdzE0 #Fedora #Linux
        )

    [1] => Array
        (
            [tweet_text] => Ubuntu 11.10 "Oneiric Ocelot" released! #Ubuntu #Linux
        )

)

Example to find Ubuntu keyword. From the current array how do I filter to show only

Array ( [1] => Array (
            [tweet_text] => Ubuntu 11.10 "Oneiric Ocelot" released! #Ubuntu #Linux
        )   
)

The code

$keywords = array('Ubuntu');

foreach ($keywords as &$keyword) {
    $keyword = preg_quote($keyword);
}

$regex = "/(" . implode('|', $keywords) . ")/";
$check = preg_match($regex, $anArray);

if($check == 1)  {
 // here I want to display only Ubuntu
}

Let me know

  • 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-27T03:24:27+00:00Added an answer on May 27, 2026 at 3:24 am

    preg_grep — Return array entries that match the pattern

    example:-

    $arr = array('k'=>'ubuntu', 'j'=>'ubuntu1', 'n'=>'fedorra');
    $matches = preg_grep('/ubuntu/i', $arr);
    

    if you original source is an multi-dimensional array,
    you can try :-

     $cmp = array();
     foreach ($src as $key=>$arr)
     {
       $cmp[$key] = $arr['tweet_text'];
     }
     $matches = preg_grep('/ubuntu/i', $cmp);
    
     // $matches will be an associate array contains the matches
     // and $matches and $src are using same index key
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$jj_post is the array output debug via print_r() . This variable is an array
I have a json output array like this { data: [ { name: Ben
Example I have this array: @packages = [2, [4, 2, 1], 4, [4,2], [5,
I will create a dynamic webshop product loader and have this i array output
The following array is output from my db. $this->db->select('code')->from('table'); $array = $this->db->get()->result_array(); //Output: Array
I have array output like this. { id = 1; user = { name=ABC
I need to get an array output as this [[1, 26], [3, 16], [3,
I have a php array output like this Array ( [DISEASE] => Array (
Consider this array string[] presidents = { Adams, Arthur, Buchanan, Bush, Carter, Cleveland, Clinton,
Given an array like this: Array => ( [0] => 1, [1] => 2,

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.