所以我有这个 foreach 循环 - 我想根据我对值的修改来修改数组.但是,当我稍后尝试将 $bizaddarray 转换为字符串时,所有 HTML 标记仍然存在.这是我的 foreach 循环 - 如何使条带标签永久化?
So I have this foreach loop - and I want to modify the array based on my modification of the values. However when I try to later convert $bizaddarray to a string, all of the HTML tags are still present. Here's my foreach loop - how can I make the strip tags permanent?
foreach ($bizaddarray as $value) {
strip_tags(ucwords(strtolower($value)));
}
两种方式,可以直接改变当前值共享的内存位置,或者使用源数组访问该值.
Two ways, you can alter the memory location shared by the current value directly, or access the value using the source array.
// Memory reference
foreach ($bizaddarray as &$value) {
$value = strip_tags(ucwords(strtolower($value)));
}
unset($value); # remove the reference
或
// Use source array
foreach ($bizaddarray as $key => $value) {
$bizaddarray[$key] = strip_tags(ucwords(strtolower($value)));
}
这篇关于如何通过 foreach 循环修改数组的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
MySQLi准备好的语句&foreach 循环MySQLi prepared statement amp; foreach loop(MySQLi准备好的语句amp;foreach 循环)
mysqli_insert_id() 是从整个服务器还是从同一用户获Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是从整个服务器还是从同一用户获取记录?)
PHP MySQLi 无法识别登录信息PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 无法识别登录信息)
mysqli_select_db() 需要 2 个参数mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 个参数)
Php mysql pdo 查询:用查询结果填充变量Php mysql pdo query: fill up variable with query result(Php mysql pdo 查询:用查询结果填充变量)
MySQLI 28000/1045 用户“root"@“localhost"的访问MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用户“root@“localhost的访问被拒绝)