method getRows documentation in bbn\X
Filters the given array which satisfies the 'where' condition.
Example
$arr = [
['id' => 1, 'first_name' => 'John', 'last_name' => 'Doe'],
['id' => 11, 'first_name' => 'Andrew', 'last_name' => 'Williams'],
['id' => 99, 'first_name' => 'Albert', 'last_name' => 'Taylor'],
['id' => 550, 'first_name' => 'Mike', 'last_name' => 'Smith'],
['id' => 7, 'first_name' => 'Mike', 'last_name' => 'Williams'],
];
X::getRows($arr, ['last_name' => 'Williams']);
// (array) [
// ['id' => 11, 'first_name' => 'Andrew', 'last_name' => 'Williams'],
// ['id' => 7, 'first_name' => 'Mike', 'last_name' => 'Williams'],
// ]
X::getRows($arr, function ($item) {
return $item['first_name'] === 'Mike' && $item['last_name'] === 'Smith';
});
// (array) [['id' => 550, 'first_name' => 'Mike', 'last_name' => 'Smith']]
function(array $ar, $where = NULL, array $order = NULL, int $limit = 0, int $start = 0)
{
$res = $ar;
if ($where) {
$res = self::filter($res, $where);
}
if ($order) {
self::sortBy($res, $order);
}
if ($start) {
array_splice($res, 0, $start);
}
if ($limit) {
return array_splice($res, 0, $limit);
}
return $res;
}
Filters the given array which satisfies the 'where' condition. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2025
BBN Solutions