How to get the same value from two arrays in PHP?

后端 未结 6 1026
小蘑菇
小蘑菇 2021-01-12 02:22

I want to get the same value from two arrays. Example:

a[] = array(a,b,c,d,e,f,g,h);
b[] = array(c,d,o,l,p,i,u,y);

I want c[]=c,d;

6条回答
  •  误落风尘
    2021-01-12 02:43

    in_array() might be what you're looking for

    Use in_array() to see if the value you're looking for is in both arrays a and b and then put it in array c (following your example)

    http://www.php.net/manual/en/function.in-array.php

提交回复
热议问题