如何在PHP中通过多个分隔符拆分字符串?
"something here ; and there, oh,that's all!"
我想将其拆分为;
,
所以经过处理后应该得到:
something here
and there
oh
that's all!
"something here ; and there, oh,that's all!"
我想将其拆分为;
,
所以经过处理后应该得到:
something here
and there
oh
that's all!
<?php
$pattern = '/[;,]/';
$string = "something here ; and there, oh,that's all!";
echo '<pre>', print_r( preg_split( $pattern, $string ), 1 ), '</pre>';
$result_array = preg_split( "/[;,]/", $starting_string );