My array is this:
$arr = Array (
' a ' = = Array (
' 1 ' = ' [large] ',
' 2 ' = ' [small] ',
' 3 ' = ' [many] ',
' 4 ' = ' [less] ',
)
' b ' = = Array (
' 1 ' = ' [you] ',
' 2 ' = ' [i] ',
' 3 ' = ' [She] ',
' 4 ' = ' [It] ',
)
)
I want to be able to find 1 at the same time as [you] can find a second level of key B.
Array_search seemingly can only find one-dimensional array, ask everyone.
Reply content:
My array is this:
$arr = Array (
' a ' = = Array (
' 1 ' = ' [large] ',
' 2 ' = ' [small] ',
' 3 ' = ' [many] ',
' 4 ' = ' [less] ',
)
' b ' = = Array (
' 1 ' = ' [you] ',
' 2 ' = ' [i] ',
' 3 ' = ' [She] ',
' 4 ' = ' [It] ',
)
)
I want to be able to find 1 at the same time as [you] can find a second level of key B.
Array_search seemingly can only find one-dimensional array, ask everyone.
Have you ever done anything similar to infinite pole classification?? Do you know how to design a table for this function??
Example: Commodity classification table
cat_id cat_name pid 1 test 0 2 test1 0 3 test3 0 4 test4 1 5 test5 2 ......
This should be familiar with, if give you a classification ID, I want to find his all sub-categories including his own How to do?? Or to find all his parents, including the tower, what??
About your problem, if you have a way to format the key name of the multidimensional array into a structure similar to the above table, then you provide a value, in the array to find the value corresponding to the key, and then in the formatted array after the search, you can get the results you want.
Iterate through each of the sub-arrays, remember the name of the array is placed into the cumulative variable, the last found when the cumulative variable output.
is actually to find the leaf node in the tree.
Don't know if it's what you want.
foreach ($arr as $key=>$value) { $ikey = array_search('[你]', $value); if ($ikey) { echo $key,'--',$ikey,'
'; }}