开发者

String Split in PHP

Good afternoon all :)

I am trying to split a string in PHP however it's not as easy as it is in C#, it seems to be a tad bit messy...

I have a string, which looks something like th开发者_高级运维is:

blahblah1323r8b|7.45

and I would like to be able to access the results of the split like this:

$var = split_result['leftside'];
$var = split_result['rightside'];

Is this easy to do in PHP? I'm trying to find some good examples, but the ones i've seen seem to be not what i'm trying to do, and a little over complicated (correct me if i'm wrong :))

Thank you :)


To get an array:

$array = explode('|', $str);

Or to directly get two parts:

list($left, $right) = explode('|', $str);

See explode in the PHP manual.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜