I currently have the code all done to filter by one keyword, but I'm wanting to filter by 100+ keywords. I'm not experienced enough in PHP, so I've tried and failed.
Here is my current code but I'm wanting to modify it to use multiple keywords.
function postResolve ($key) {
return isset($_POST[$key]) ? $_POST[$key] : null;
}
$formData = [
'keyword' => postResolve('keyword'),
'text' => postResolve('text')
];
if (is_null($formData['keyword']) || is_null($formData['text'])) {
return 'Nothing to do... Missing text or keyword.';
}
$text = explode(PHP_EOL, $formData['text']);
$storage = [];
foreach ($text as $sentence) {
if (strpos($sentence, $formData['keyword']) !== false) {
$storage[] = trim($sentence);
}
}
echo json_encode($storage);
Would appreciate if someone could give me a hand on this change :)