PHP更改文件格式
我的图像文件格式存储在mongo db中,如下所示: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:
"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\"]");
?>