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.
精彩评论