我试图在 foreach 循环中获取 $current_account ,直到 fooreach 循环结束。我正在使用 next 函数,它为我提供数组中的下一个元素,直到它到达末尾。到达数组末尾后,如何使其转到数组中的第一个元素?
$search_tags = array(
"happy",
"summer",
"beach",
"glasses",
"umbrella",
"funny",
"people",
"music",
"rap"
);
$accounts = array(
"account A",
"account B",
"account C"
);
foreach ($search_tags as $tag) {
$current_account = current($accounts);
print_r($current_account."\n");
};
所以在这种情况下,结果应该是这样的:
账户B 账户C 账户A 账户B 账户C 账户A 账户B 账户C 账户A
但我得到以下信息:
账户 B 账户 C