Prefix filtering in php

How can I write a php program to find all arrays that share at least one element in their prefixes. Let the prefixes make up one quarter of all the elements in each array. Can someone help me code for this? I am new to php. I need this to do an almost double detection project.

+3
source share
1 answer

You can use PHP's built-in array function array_intersect

if(array_intersect($firstArray, $secondArray) == null)
{
    //do not have any element common
}
else 
{
    //have at least one element common
}

you can create a function of this code and pass all pairs of pairs to get the result.

0
source

Source: https://habr.com/ru/post/1781578/


All Articles