PHP array_filter() function filters elements of an array using a callback function and returns the filtered array. Here we’ll provide a PHP code to filter elements of an array that contain a specific value. It will help you to filter an array based on particular condition. The following example code will filter the elements of a multidimensional array by value using array_filter() functions in PHP. $newArr = array( array( 'name' => 'Fine', 'amount' => 1000 ) , array( 'name' => 'Transport Fee', 'amount' => 0 ) , array( 'name' => 'Cheque Bounce', 'amount' => 50 ) , array( 'name' => 'TC', 'amount' => 100 ) ); $filterArray = array_filter($newArr, function ($var) { return ($var['amount'] != 0); }); // Output the filtered array print_r($filterArray); //OUTPUT Array( [0] => Array( [name] => Fine [amount] => 1000 ...
Experienced Developer with a demonstrated history of working in the information technology and services industry. Skilled in AngularJs, Nodejs, Laravel, Codeigniter , WordPress. Strong engineering professional with a Master of Computer Applications (MCA) focused in Information Technology.