【发布时间】:2019-04-29 01:24:11
【问题描述】:
我有两个这样的数组:
$path = array("Login", "Register");
$list = array("Admin", "Customers", "Guest");
for ($i=0, $i<=count($path), $i++, $k=0; $k<=count($list); $k++) {
echo "Var " . $path[$i] . " is " . $list[$k] . "\n";
}
输出:
Var Register is Admin
Var Register is Customers
Var Register is Guest
<br />
<b>Notice</b>: Undefined offset: 3 in <b>[...][...]</b> on line <b>6</b><br />
Var Register is
我需要输出这个
Var Login is Admin
Var Login is Customers
Var Login is Guest
Var Register is Admin
Var Register is Customers
Var Register is Guest
有解决办法吗?
【问题讨论】:
-
@RolandStarke 可以写代码吗?
-
@alifiaavirista - 你有没有想过使用dictionary?
-
欢迎来到 stackoverflow.com。请花一些时间阅读help pages,尤其是名为"What topics can I ask about here?" 和"What types of questions should I avoid asking?" 的部分。也请take the tour 阅读how to ask good questions。最后请阅读this question checklist。
标签: php arrays for-loop unique