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

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

WBOY
Release: 2016-06-23 14:06:31
Original
1022 people have browsed it

请教,我现有这么一串数据
前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
Copy after login

想找相关代码将以上数据按换行符进行反转
即应得到如下结果:
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
Copy after login

谢谢各位


回复讨论(解决方案)

$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); // 组合

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