str_replace() for multiple value replacement

后端 未结 6 1468
Happy的楠姐
Happy的楠姐 2020-12-03 10:30

Is there any possibility to use str_replace for multiple value replacement in a single line. For example i want to replace \' \' with \'-\'

6条回答
  •  余生分开走
    2020-12-03 10:58

    This is how I did it to replace ' to '' so it doesn't break in SQL queries and " " with "" because people kept adding a space at the end of their emails:

    $check = str_replace("'","''",$_POST['1']);
    $checkbox1 = str_replace(" ","",$check);
    

    For yours you could do this:

    $check = str_replace("&","",$_POST['1']);
    $checkbox1 = str_replace(" ","-",$check);
    

提交回复
热议问题