<?php
// destroy a single variable
unset($foo);
// destroy a single element of an array
unset($bar['quux']);
// destroy more than one variable
unset($foo1, $foo2, $foo3);
?>
或
@php
// destroy a single variable
unset($foo);
// destroy a single element of an array
unset($bar['quux']);
// destroy more than one variable
unset($foo1, $foo2, $foo3);
@endphp
3条答案
按热度按时间brjng4g31#
从the
foreach
docs开始:$value
的引用和最后一个数组元素即使在foreach
循环后仍保留,建议通过unset()
销毁因此,如果要销毁引用,请执行以下操作:
或者:
rfbsl7qr2#
建议通过unset()销毁
xyhw6mcr3#
根据你的问题,你可以使用php的unset()方法来销毁一个变量。
为此,您可以在foreach循环之后在blade文件中使用这种类型的代码。
或