Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/250.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP更改文件格式_Php_File_Format - Fatal编程技术网

PHP更改文件格式

PHP更改文件格式,php,file,format,Php,File,Format,我的图像文件格式存储在mongo db中,如下所示: "image_val": "[\"\\/attachments\\/seonotes\\/357\\/selection_007-1498621634.png\"]" 我从表中获取值并将其放入变量中 $image_val = "[\"\\/attachments\\/seonotes\\/357\\/selection_007-1498621634.png\"]"; 我可以得到下面的$image_val吗(去掉括号和斜线) 方法1:

我的图像文件格式存储在mongo db中,如下所示:

 "image_val": "[\"\\/attachments\\/seonotes\\/357\\/selection_007-1498621634.png\"]"
我从表中获取值并将其放入变量中

$image_val = "[\"\\/attachments\\/seonotes\\/357\\/selection_007-1498621634.png\"]";
我可以得到下面的$image_val吗(去掉括号和斜线)


方法1:

 <?php
    echo str_replace("\\","","[\"\\/attachments\\/seonotes\\/357\\/selection_007-1498621634.png\"]");
    ?>
您可以使用和:

:删除斜杠

:从结果字符串中替换
[“
”]


方法2:

 <?php
    echo str_replace("\\","","[\"\\/attachments\\/seonotes\\/357\\/selection_007-1498621634.png\"]");
    ?>
您可以使用和:

:删除斜杠


:从字符串的开头和结尾修剪括号

尝试以下方法:

 <?php
    echo str_replace("\\","","[\"\\/attachments\\/seonotes\\/357\\/selection_007-1498621634.png\"]");
    ?>

你的问题是什么?
 <?php
    echo str_replace("\\","","[\"\\/attachments\\/seonotes\\/357\\/selection_007-1498621634.png\"]");
    ?>
<?php
  echo str_replace(array( '["', '"]', '\\' ),"","[\"\\/attachments\\/seonotes\\/357\\/selection_007-1498621634.png\"]");
?>