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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:34:10+00:00 2026-05-28T03:34:10+00:00

I am trying to extract some checkboxes values into an array. My problem is

  • 0

I am trying to extract some checkboxes values into an array. My problem is array($is_types). I am expecting $is_types to be an array, say array(one, two, three):

<?php
  if (!is_array($types)) {
    $types = array();
  }
  $filtered_array = array_filter($types);

 $is_types = in_array($type, $filtered_array);

  $output = _get_array(array($is_types), $bla, $bla2);
?>

UPDATE:
I need to rephrase what I am trying to achieve.
I have some checkboxes with options: one, two, three, etc. Only when I check them, the options should be stored. Checking what are stored is enough with $is_types, returning the bool.
Then I have a need to do other queries to aggregate content based on these checked checkboxes. That is if I have an array(one, two, three), based on the filtered checkboxes, then run the query

UPDATE2:

function _get_array($type, $view_mode, $limit = NULL) {

  $node = menu_get_object();
  $build = array();

  $query = new EntityFieldQuery();
  $created = isset($node) ? $node->created : 'now';
  $query
    ->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', $type, is_array($type) ? 'IN' : '=')
    ->propertyCondition('status', 1)
    ->propertyOrderBy('created', 'DESC')
    ->propertyCondition('created', $created, '<');

  if ($limit != NULL) {
    $query->range(0, $limit);
  }

  $result = $query->execute();

  if (!empty($result['node'])) { 
    $nodes = entity_load('node', array_keys($result['node']));
    $build[] = node_view_multiple($nodes, $view_mode);

  }
  return !empty($build) ? $build : array();
}

The checkboxes are just checkboxes with some values.
So querying _get_array(array($is_types), $bla, $bla2); should load all nodes filtered by these checkboxes value.

Any hint would be very much appreciated. Thanks

UPDATE3:
Thanks to all. The answer was there all along. What I need seems just: $filtered_array

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

    OK, I understand what you mean. You probably have the following HTML…

    <input type="checkbox" name="test" value="one"/>
    <input type="checkbox" name="test" value="two"/>
    <input type="checkbox" name="test" value="three"/>
    

    And on the server, you want an array containing one, two or three depending on which were selected.

    Basically, you have to add square brackets to ‘test’ to tell PHP to consider test as an array, like so:

    <input type="checkbox" name="test[]" value="one"/>
    <input type="checkbox" name="test[]" value="two"/>
    <input type="checkbox" name="test[]" value="three"/>
    

    And on the server, you simply access this as follows:

    print_r( $_REQUEST['test'] );
    

    Beware that if none of the options were selected, you won’t get an array. Instead, do the following:

    $options = isset( $_REQUEST['test'] ) ? $_REQUEST['test'] : array();
    

    To ensure all variables are legit, do the following:

    $legit = array('one','two','three');
    
    foreach($options as $n=>$option)
        if(!in_array( $option, $legit ))
            unset( $options[ $n ] );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to extract some information from a webpage using php cURL+preg_match or any
I am trying to extract some words from a string. The two cases look
I'm trying to extract all words from a string into an array, but i
I'm trying to extract some functionality from my existing app into a gem. The
I am trying to ultimately extract some files from a tar archive within PHP,
Trying to parse an HTML document and extract some elements (any links to text
I am trying to use XPath to extract some HTML tags and data and
I'm trying to use WWW::Mechanize to extract some links from the HTML page using
I'm trying to extract monetary sums stored in some poorly formated xml columns (there
I'm trying to write some code to extract Exif information from a JPG. Exif

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.