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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:57:20+00:00 2026-06-12T06:57:20+00:00

Trying to pass a closure into filter_var_array(), but can’t seem to make it work.

  • 0

Trying to pass a closure into filter_var_array(), but can’t seem to make it work.

$clean = function( $html ) {
    return HTML::sanitize( $html, array('p','ul','ol','li'), array('class','style') );
};
$args = array( 'filter' => FILTER_CALLBACK, 'options' => $clean );

$fields = filter_var_array(
    array( $_POST['field1'], $_POST['field2'], $_POST['field3'] ),
    array( 'field1' => $args, 'field2' => $args, 'field3' => $args )
);

After the above is run, $fields is an empty array.

Note, individual filtering works fine:

$field1= filter_var( $_POST['field1'], FILTER_CALLBACK, array( 'options' => $clean ) );

Any ideas?

  • 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-12T06:57:21+00:00Added an answer on June 12, 2026 at 6:57 am

    You are passing in the values of $_POST without their keys, hence no callbacks will be triggered. Just pass in the entire $_POST array instead, e.g.

    $fields = filter_var_array(
        $_POST,
        array(
            'field1' => $args, 
            'field2' => $args, 
            'field3' => $args 
        )
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to pass a variable into the the google chart but when I
Trying to pass a string argument to a function, which will then be used
im trying to pass two parameters to a function, i being an int value
When trying to pass a CGPoint to a method the point is passed, but
I am trying to use a lambda to pass in place of a function
Iam trying to pass dynamic argument values i.e username from request using spring ioc.But
Trying to pass the values but not making progress. Scenario : Have a public
Trying to pass some values into an imagebutton click event, something like this: <asp:ImageButton
Im trying to pass parameters to myFunction, but it seems to be causing issues
Im trying to pass an array that I already found by a query into

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.