从数组中获取值并在字符串PHP中搜索它

I'm trying to get a values from the following array:

$array = ["jack", "name", "father"];

Then i want to get back the line of where the word appears in in the following string:

$story = "Hello, my name is jack and i'm in the army. I've been in the army for 10 years. My father was also in the army.";

The outcome should be:

"Hello, my name is jack and i'm in the army. My father was also in the army.";

This is custom way to get desire Output string

<?php
$array = ["jack", "name", "father"];
$story = "Hello, my name is jack and i'm in the army. I've been in the army for 10 years. My father was also in the army.";
$return = [];
$splitStory = explode(".", $story);
$data = array_filter($splitStory);
//echo "<pre>";
//print_r(array_filter($splitStory));
$count = count($data);
$count2 = count($data);
for($i=0; $i < $count; $i++)
{
    for($j=0; $j < $count2; $j++)
    {
        if (strpos($data[$i], $array[$j]) !== false) {
            $return[] = $data[$i];
        } 
    }
}
$returnArray = array_unique($return);
$returnStr = implode(".", $returnArray);
echo $returnStr;  // Output : Hello, my name is jack and i'm in the army. My father was also in the army
?>
  1. array_unique() Function :- The array_unique() function removes duplicate values from an array. If two or more array values are the same, the first appearance will be kept and the other will be removed.
  2. array_filter() Function :- The array_filter() function filters the values of an array using a callback function.
  3. explode() Function :- The explode() function breaks a string into an array.
  4. implode() Function :- The implode() function returns a string from the elements of an array.