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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:56:19+00:00 2026-05-13T15:56:19+00:00

I have this huge array: array(47) ( name => string(0) state => string(7) Alabama

  • 0

I have this huge array:

array(47) (
    "name" => string(0) ""
    "state" => string(7) "Alabama"
    "city" => string(0) ""
    "country" => string(13) "United States"
    "location" => string(0) ""
    "rooms" => string(0) ""
    "price" => string(0) ""
    "highlights" => array(5) (
        0 => string(0) ""
        1 => string(0) ""
        2 => string(0) ""
        3 => string(0) ""
        4 => string(0) ""
    )
    "specifications_type" => string(0) ""
    "specifications_lotsize" => string(0) ""
    "specifications_apn" => string(0) ""
    "specifications_interest" => string(0) ""
    "specifications_year" => string(0) ""
    "specifications_buildings" => string(0) ""
    "specifications_stories" => string(0) ""
    "specifications_corridors" => string(0) ""
    "financials_room" => string(0) ""
    "financials_other" => string(0) ""
    "financials_total" => string(0) ""
    "financials_multiplier" => string(0) ""
    "financials_caprate" => string(0) ""
    "financials_netincome" => string(0) ""
    "amenities_pool" => string(0) ""
    "amenities_fitness" => string(0) ""
    "amenities_quarters" => string(0) ""
    "amenities_services" => string(0) ""
    "amenities_spa" => string(0) ""
    "amenities_meetspace" => string(0) ""
    "amenities_parkspace" => string(0) ""
    "amenities_others" => string(0) ""
    "facilities_room" => string(0) ""
    "facilities_hvac" => string(0) ""
    "facilities_furnitures" => string(0) ""
    "facilities_tv" => string(0) ""
    "facilities_ref" => string(0) ""
    "facilities_microwave" => string(0) ""
    "consumables_resto" => string(0) ""
    "consumables_restocpct" => string(0) ""
    "consumables_barlounge" => string(0) ""
    "consumables_barloungecpct" => string(0) ""
    "consumables_bevrevenue" => string(0) ""
    "consumables_others" => string(0) ""
    "specifications" => string(100) "{"type":"","lotsize":"","apn":"","interest":"","year":"","buildings":"","stories":"","corridors":""}"
    "consumables" => string(89) "{"resto":"","restocpct":"","barlounge":"","barloungecpct":"","bevrevenue":"","others":""}"
    "amenities" => string(100) "{"type":"","lotsize":"","apn":"","interest":"","year":"","buildings":"","stories":"","corridors":""}"
    "facilities" => string(100) "{"type":"","lotsize":"","apn":"","interest":"","year":"","buildings":"","stories":"","corridors":""}"
    "financials" => string(100) "{"type":"","lotsize":"","apn":"","interest":"","year":"","buildings":"","stories":"","corridors":""}"
)

I want to remove the elements whose keys start with any of the following:
“specifications_”, “amenities_”, “facilities_”, “consumables_”, “financials_”

I have thought of using array_filter with a callback but I have no idea how to do things in the callback. Please help.

  • 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-13T15:56:20+00:00Added an answer on May 13, 2026 at 3:56 pm

    You can’t actually use array_filter() for this because it preserves keys but you can’t filter on keys, which is your problem. In that case you may as well just loop.

    $prefix = array(
      'specifications_',
      'amenities_',
      'facilities_',
      'consumables_',
      'financials_',
    );
    
    $output = array();
    foreach ($input as $k => $v) {
      foreach ($prefix as $p) {
        $add = true;
        if (strpos($k, $p) === 0) {
          $add = false;
          break;
        }
      }
      if ($add) {
        $output[$k] = $v;
      }
    }
    

    Now this works reasonably well so long as the list of prefixes isn’t that large and the array isn’t that large but there is no need to overcomplicate the solution unless you need it.

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

Sidebar

Ask A Question

Stats

  • Questions 459k
  • Answers 459k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Assuming the compile-time type of some_obj implements Closeable, then yes,… May 15, 2026 at 11:25 pm
  • Editorial Team
    Editorial Team added an answer EDIT: Changed to include clearer requirements. Given a list that… May 15, 2026 at 11:25 pm
  • Editorial Team
    Editorial Team added an answer This is the most common use of std::mem_fun and std::mem_fun_ref.… May 15, 2026 at 11:25 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.