donglingyi4679 2015-04-27 12:22
浏览 42
已采纳

如何在PHP中使用分隔符拆分字符串? [关闭]

I have a string

1b00bd515bf8cbc5a86f3b714361fab6

and I want to break it down like this:

1b00bd51-5bf8cbc5-a86f3b71-4361fab6

How can I do this?

  • 写回答

4条回答 默认 最新

  • dongyan2469 2015-04-27 12:27
    关注

    use chunk_split function split a string into smaller chunks

    below:

    $str = "1b00bd515bf8cbc5a86f3b714361fab6";
    
    $str = trim(chunk_split(str_replace('-','',$str), 8, '-'), '-');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?