Home > Backend Development > PHP Tutorial > 字符串有关问题

字符串有关问题

WBOY
Release: 2016-06-13 13:41:46
Original
954 people have browsed it

字符串问题
有一个字符串:ETC56-542NA1,如何变成 ETC56-542N A1这样?

------解决方案--------------------
貌似 php字符串函数里面很多歌函数都能实现这效果 chunk_split() 
$a="ETC56-542NA1";
echo chunk_split("$a",10," ");
随便写一个不知能否实现


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

PHP code

<?php $s='ETC56-542NA1';
    echo substr(chunk_split($s,strlen($s)-2,' '),0,-1);
?> <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template