通过最后一个分隔符的外观拆分 [英] Split a tring by the appearance of last delimiter

查看:81
本文介绍了通过最后一个分隔符的外观拆分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



在PHP中,我只想从分隔符中分割一个字符串。



Hi all,

In PHP I just want to split a string, from a delimiter.

$str = "one/two/three";

$arr = explode('/', $str);





我只想把这个int拆分为最大的两个数组。所以我可以这样做。





I just want to split this int to maximum arrays of two. So I can do it as follows.

$str = "one/two/three";

$arr = explode('/', $str, 2);





所以输出结果是,



一个

两个/三个



但是,我想将它拆分为,



一/二





我该怎么做?



So the output will be,

one
two/three

But, I want to split it as,

one/two
three

How can I do that?

推荐答案

str = 一/二/三;

str = "one/two/three";


arr = explode(' /'


str);





我只想将此int拆分为最大的两个数组。所以我可以这样做。





I just want to split this int to maximum arrays of two. So I can do it as follows.


这篇关于通过最后一个分隔符的外观拆分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆