Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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)));
    }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
474 views
Welcome To Ask or Share your Answers For Others

1 Answer

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

Or

// Use source array
foreach ($bizaddarray as $key => $value) {
    $bizaddarray[$key] = strip_tags(ucwords(strtolower($value)));
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...