我有类似的例子
$str = 'wap,net,web,andothers';
在我的成就中我想从字符串行中删除web,所以我的预期结果应该像wap,net和我尝试的其他
$str = 'wap,net,web,andother';
$remove = 'web';
$str = ltrim($str, ' $remove');
var_dump($str);
但无法实现
非常感谢提前
在这里我爆炸它然后过滤掉关键字web
<?php
$str = 'wap,net,web,andother';
$explode = explode(',',$str);
$result = [];
foreach($explode as $value){
if($value !== 'web'){
$result[] = $value;
}
}
print_r(implode(',',$result));
?>
或者简单地说,使用php str_replace
$str = 'wap,net,web,andother';
$stringToRemove = 'web';
print_r(str_replace($stringToRemove,'',$str));