Home >Backend Development >PHP Tutorial > PHP的explode如何才能做到这样子

PHP的explode如何才能做到这样子

WBOY
WBOYOriginal
2016-06-13 12:51:09945browse

PHP的explode怎么才能做到这样子?
$userdomain="1,2,3,4,5";

$piece = explode(",", $userdomain);
$name0=$piece[0];
$name1=$piece[1];
$name2=$piece[2];
$name3=$piece[3];
$name4=$piece[4];

echo "$name0 $name1 $name2 $name3 $name4";

这样输出为12345

怎么写,可以输出54321

当然得保持echo "$name0 $name1 $name2 $name3 $name4";
而不是echo "$name4 $name3 $name2 $name1 $name0";

就是怎么样让explode倒序输出?


------解决方案--------------------
先explode 再array_reverse反正数组
------解决方案--------------------
$piece = array_reverse(explode(",", $userdomain));
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