开发者

String Split in PHP

开发者 https://www.devze.com 2023-01-26 09:20 出处:网络
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...

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

精彩评论

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