Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在制作一个关于 dict 的页面。我需要写一个循环来foreach他们。为了显示每个标题,我需要获取数组的名称。(每个标题的名称就是数组的名称)
我在这里有一个数组:
$a = array('num1', 'num2'); $b = array('num1', 'num2'); $c = array('num1', 'num2'); $z = array('num1', 'num2');
如何获得它的名字a,b,c,z?
你可以做一个数组:
$arrays = array( 'a' => $a, 'b' => $b, 'c' => $c, 'd' => $d );
并通过 foreach 您访问他们的名字:
foreach($arrays as $array_name => $array) { ... }