I am trying to sort out a multidimensional array based on an array of keys (query params), but am having no luck in doing so.
我正在尝试根据一组键(查询参数)对一个多维数组进行排序,但是这样做没有运气。
Array From DB:
从DB数组:
AOD (Array, 2 elements)
topic (String, 21 characters ) Alcohol & Other Drugs
lessons (Array, 29 elements)
CEH (Array, 2 elements)
topic (String, 25 characters ) Community & Environmental
lessons (Array, 23 elements)
Array of Keys (Query String):
键的数组(查询字符串):
0 (String, 3 characters ) AOD
1 (String, 3 characters ) CEH
So, if I only passed in AOD
, then the first array above would only return the multi-dimensional array of AOD
所以,如果我只在AOD中传递,那么上面的第一个数组只会返回AOD的多维数组。
Code:
代码:
array_intersect($snsData, array_flip($query_topics))
1 个解决方案
#1
0
Working Code:
工作代码:
array_intersect_key($snsData, array_flip($query_topics))
Where $query_topics
is an array of $_GET params
$query_topic是$_GET params的数组
#1
0
Working Code:
工作代码:
array_intersect_key($snsData, array_flip($query_topics))
Where $query_topics
is an array of $_GET params
$query_topic是$_GET params的数组