php中如何优雅的将一个字符串打乱顺序然后输入(不利用数组)?

WBOY
Release: 2016-06-06 20:27:47
Original
1481 people have browsed it

后台返回的字符串,需要将字符串中字符的顺序打乱然后输出,我想到了将字符串切割成数组,然后利用数组的shuffle()将数组打乱,最后将数组拼接成字符串再输出,但是这样感觉效率太低,如何优雅的实现这个需求?

回复内容:

后台返回的字符串,需要将字符串中字符的顺序打乱然后输出,我想到了将字符串切割成数组,然后利用数组的shuffle()将数组打乱,最后将数组拼接成字符串再输出,但是这样感觉效率太低,如何优雅的实现这个需求?

<code class="php">echo str_shuffle('http://segmentfault.com/q/1010000003776023');//q/20730hg/a70fptlnee6t3s0/11t/:otucm00.0m0</code>
Copy after login
Related labels:
php
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!