Skip to content

Commit 8d3b419

Browse files
committed
Add simple usage examples
1 parent a58fe16 commit 8d3b419

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,21 @@
11
# An unofficial PHP implementation of JsonLogic
2+
3+
### Usage
4+
5+
- For an one-time logic to data use case, the `apply` function is enough:
6+
7+
```php
8+
echo \JsonLogic\JsonLogic::apply($rule, $data);
9+
```
10+
11+
- For a rule runs tons times, e.g. find matched records in daily logs:
12+
13+
```php
14+
$rule = \JsonLogic\JsonLogic::rule($rule);
15+
16+
var_dump(
17+
array_filter($logs, function ($log) use ($rule) {
18+
return $rule->process($log);
19+
})
20+
);
21+
```

0 commit comments

Comments
 (0)