本文介绍了如何通过 foreach 循环修改数组的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!
问题描述
所以我有这个 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 循环修改数组的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!
The End



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)