Home  >  Article  >  Backend Development  >  PHP字符串替换及日期格式转换的有关问题,请问

PHP字符串替换及日期格式转换的有关问题,请问

WBOY
WBOYOriginal
2016-06-13 13:29:24718browse

PHP字符串替换及日期格式转换的问题,请教!
$str=[['1','2','3'],['4','5','6'],['7','8','9']];
我想把以上字符串中所有"["替换成"array(",所有"]"替换成")"。
$str="2012年1月1日";
如何把以上日期格式转换成"2012-01-01"?
谢谢!

------解决方案--------------------

PHP code


$str="[['1','2','3'],['4','5','6'],['7','8','9']]";

$newstr=str_replace("[",'array(',$str);

$newstr=str_replace("]",')',$newstr);

echo $newstr; <div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn