Home >Backend Development >PHP Tutorial >请教,php中如何按换行符倒序排列

请教,php中如何按换行符倒序排列

WBOY
WBOYOriginal
2016-06-23 14:06:311020browse

请教,我现有这么一串数据
前5行数据为:

130424007	76346	2013-04-24 00:35:00130424006	56677	2013-04-24 00:30:00130424005	11174	2013-04-24 00:25:00130424004	69889	2013-04-24 00:20:00130424003	15983	2013-04-24 00:15:00

想找相关代码将以上数据按换行符进行反转
即应得到如下结果:
130424003	15983	2013-04-24 00:15:00130424004	69889	2013-04-24 00:20:00130424005	11174	2013-04-24 00:25:00130424006	56677	2013-04-24 00:30:00130424007	76346	2013-04-24 00:35:00

谢谢各位


回复讨论(解决方案)

$str =  130424007    76346    2013-04-24 00:35:00
130424006    56677    2013-04-24 00:30:00
130424005    11174    2013-04-24 00:25:00
130424004    69889    2013-04-24 00:20:00
130424003    15983    2013-04-24 00:15:00
txt;
$arr = explode("\n", $str); // 拆分
$arr = array_reverse($arr); // 反转
$str = implode("\n", $arr); // 组合

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
Previous article:PHP执行实时进度Next article:apache 配置 https