There is an array_intersect
function that does pretty much what you need. If you want to compare the elements using regular expressions, try preg_grep
, but you will need to prepare the pattern first.
如何在两个数组中找到共同元素? [关闭]
There are two arrays. It is necessary to display a list from the first array on the page, in which the elements of the second array will be highlighted, for example with a color. Probably it is necessary to read one array in a loop and compare, for example preg_match with the second array and if there is a coincidence - to allocate. Does anyone have a more beautiful solution?
- 点赞
- 写回答
- 关注问题
- 收藏
- 复制链接分享
- 邀请回答
1条回答
为你推荐
- 如何在两个数组中找到共同元素? [关闭]
- php
- 1个回答