Skip to content

Instantly share code, notes, and snippets.

View abdennor's full-sized avatar
🎯
Focusing

Abdelraouf Ferah abdennor

🎯
Focusing
View GitHub Profile
@abdennor
abdennor / filterArray.js
Created May 17, 2022 15:16 — forked from jherax/arrayFilterFactory.1.ts
Filters an array of objects with multiple match-criteria.
/**
* Filters an array of objects using custom predicates.
*
* @param {Array} array: the array to filter
* @param {Object} filters: an object with the filter criteria
* @return {Array}
*/
function filterArray(array, filters) {
const filterKeys = Object.keys(filters);
return array.filter(item => {
<?php
/// result from db
// cause_id/cause_parent_id are for the relation parent/child
// challangers is the name of children array
$db_result = array(
array(
"cause_id" => 1,
"cause_parent_id" => 1,
"name" => "my title 1"
),