Using array_filter function in thinkphp5

The array_filter function is used in

thinkphp5, and the second parameter is wrong. Ask the god how to modify it. Thank you

<?php  
namespace app\controller;  
class Abs
{
    public function index(){
        function abc($value){
            if($value!==""){
                return true;
            }else{
                return false;
            }
        }

        $data = [
            "a"=>1,
            "b"=>0,
            "c"=>true,
            "d"=>false,
            "e"=>0,
            "f"=>"",
            "d"=>null
        ];
    
        return array_filter($data,"abc");
    }
}

error report:
array_filter () expects parameter 2 to be a valid callback, function "abc" not found or invalid function name

Php
Nov.09,2021

is related to namespace. Just specify namespace.

return array_filter($data,'\app\controller\abc');

you can write this way

public function index(){
        

        $data = [
            'a'=>1,
            'b'=>0,
            'c'=>true,
            'd'=>false,
            'e'=>0,
            'f'=>'',
            'd'=>null
        ];
    
        return array_filter($data,function($value){
            if($value!==''){
                return true;
            }else{
                return false;
            }
        });
    }

what is the specific error message?


the second parameter requires a callback function, which abc does not have
function abc ()
{
return true;
};

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb3d08-48259.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb3d08-48259.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?