We have a script:

$trr = '<div class="category"><a href="#" rel="tag" title="">продукция</a> <a href="#" rel="tag" title="">хозяйство</a> <a href="#" rel="tag" title="">хранение</a></div>'; $sttr = $trr.'<div class="actions_tags"><a href='#'>продукция</a>, <a href='#'>хранение</a></div>'; preg_match('|<div class="category">(.*)</div>|Uis', $sttr, $p_category); preg_match('|<div class="actions_tags">(.*)</div>|Uis', $sttr, $p_keywords); $p_keywords[1] = strip_tags($p_keywords[1]); $p_category[1] = strip_tags($p_category[1]); 

The list of words in the $ sttr variable is always separated by a comma, the content changes. We need to remove the matching of the variable data from $ p_category with the $ p_keywords variable.

Those. if in the $ p_category variable we had the data “Hello, how are you, this film will be released soon, don't you know?”, and in the $ p_keywords variable there was data “how are you, you do not know”, then the result should be “Hello, will this movie be out soon? " however, the removal / non-removal of these commas is not critical.

How to implement it? Related question: link .

    2 answers 2

    Well, for this you need to use a PHP function that calculates the difference in arrays -

    array_diff(array $array1,array $array2[, array ...])

    It returns an array consisting of the values ​​of the array $ array1 , which are not found in any other array listed in the subsequent arguments. How to use it in your case is already you and you are able to reach it =)

      explode + array_intersect