我有一个像这样的数组:
Array
(
[0] => "<[email protected] /cdn-cgi/l/email-protection>"
[1] => "<[email protected] /cdn-cgi/l/email-protection>"
[2] => "<[email protected] /cdn-cgi/l/email-protection>"
)
现在我想删除"<"
and ">"
从上面的数组,使它看起来像
Array
(
[0] => "[email protected] /cdn-cgi/l/email-protection"
[1] => "[email protected] /cdn-cgi/l/email-protection"
[2] => "[email protected] /cdn-cgi/l/email-protection"
)
如何在 php 中做到这一点?请帮帮我。
我在用着array_filter()
;有没有更简单的方法可以做到这一点,除了array_filter()
?
你可以对其进行 array_walk :
// Removes starting and trailing < and > characters
function trim_gt_and_lt(&$value)
{
$value = trim($value, "<>");
}
array_walk($array, 'trim_gt_and_lt');
但请注意,这将also删除开始>
和尾随<
这可能不是你想要的。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)