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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:27:19+00:00 2026-06-11T11:27:19+00:00

I have the follow array: Array ( [0] => Array ( [type] => foo

  • 0

I have the follow array:

Array
(
    [0] => Array
        (
            [type] => foo
        )

    [1] => Array
        (
            [type] => bar
        )

    [2] => Array
        (
            [type] => bar
        )
)

and need to know if exists one or more type which value is bar, without do this:

foreach ($arrayOfTypes as $type) {
    if ($type['type'] == 'bar')
    {
        // Stuff here
    }
}

(Only for learning purposes)

  • 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-11T11:27:20+00:00Added an answer on June 11, 2026 at 11:27 am

    I’d go with array_filter();

    $filteredArray = array_filter($stuff, function($item){
    
        return $item['type'] == 'bar';
    
    });
    
    if( count($filteredArray) > 0 ){
    
        echo 'There was a bar item in array.';
    
    }else{
    
        echo 'No luck sorry!';
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume that I have two arrays as follow: $array1 = array(1, 3, 5); $array2
We have a WSDL which contains the following type definition: ... <xsd:complexType name=OrderItem> <xsd:all>
I know the benefits of chaining within PHP but lets say we have this
I'm trying to follow along with http://mongotips.com/b/array-keys-allow-for-modeling-simplicity/ I have a Story document and a
I have the follow code, which get $_GET and make division by controller, action
I have have an array as follows: $row when I output the entire array
I have a double array as follows: $values[$ids][$dates] So for each $id I have
I have php code that puts some values into an Array as follows: $hunter=addslashes($MessageArray[1]);
For development of web services, i have to make multilevel Associative array as follows
Background I have an array of objects (Users) defined and set as follows: //

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.