我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

在php中替换\“with”

How to replace \" with " from a string in php and to remove \ from end of a string? My line of code is like :

$field[] = str_replace('\\"', '"', trim($val, '\\'));

But this is not working..somebody please help me

You can do it with default function - stripslashes:

$val = '"hell\"ooo\\';
echo stripslashes($val);

Or if you need with str_replace:

$val = '"hell\"ooo\\';
echo str_replace('\\"', '"', trim($val, '\\'));

Result would be:

"hell"ooo

近期文章

  • 使用302重定向表单
  • 使用PHP和MySql创建考勤表
  • Unity3D到PHP的安全问题
  • 在framework7 app中显示DB数据
  • 如何为获取值重写url?
  • 带有select(选项)框的RSS php阅读器
  • 使用javascript和Ajax POST形成JSON [LARAVEL]
  • Google OAuth2验证服务器流中的访问令牌
  • 如果两个数组中的任何元素匹配,则返回true? [重复]
  • 如何查看YouTube视频网址现在正在验证?
  • 如何使用file_get_contents获取结果数
  • 分页限制和偏移在codeigniter中不起作用
  • Apache2与web.py和php - php服务无法正常工作
  • 在创建表单时调用null上的成员函数get()
  • 使用php将表从在线sql server复制到本地服务器
  • 在自己的表中为多个集使用相同的模板
  • Php重写Url .htaccess文件
  • Htaccess索引文件,如果存在
  • 使用Forward Rewrite时,Wordpress wp-login重定向到错误的url
  • (PHP)如何使用值数组替换字符串中的不同子串?

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华