代码:
$str = 'test2$test2$test3$test3$test4';
$id = 'test2';
我们需要找到$id的值并根据字符串中的位置test2删除$test2或test2$ ;
要使用搜索:
$substr_count1 = substr_count ($str, '$test2');
$substr_count2 = substr_count ($str, 'test2$');
if ($substr_count1> 0) {
//if exist $test2 then need delete single value $test2 from row and row will be
// $str = 'test2$test3$test3$test4'
// find the value of $test2
// how to remote one value $test2
}
elseif ($substr_count2> 0) {
//if exist test2$ then need delete single value test2$ from row and row will be
// $str = 'test2$test3$test3$test4'
// find the value of test2$
// how to remote one value test2$
}
如何删除单个值?