preg_split( '/[,|]/', $f_usernames, -1, PREG_SPLIT_NO_EMPTY );

<?php
$f_usernames='jim green,tom hanks|wilson shi';
$t_usernames = preg_split( '/[,|]/', $f_usernames, -1, PREG_SPLIT_NO_EMPTY );
var_dump($t_usernames);
/*
array (size=3)
  0 => string 'jim green' (length=9)
  1 => string 'tom hanks' (length=9)
  2 => string 'wilson shi' (length=10)
*/

 

<?php
$f_usernames='jim green,tom hanks|wilson shi,    ,,lucy     |   ||    Lily';
$t_usernames = preg_split( '/[,|]/', $f_usernames, -1, PREG_SPLIT_NO_EMPTY );
var_dump($t_usernames);
/*
array (size=7)
  0 => string 'jim green' (length=9)
  1 => string 'tom hanks' (length=9)
  2 => string 'wilson shi' (length=10)
  3 => string '    ' (length=4)
  4 => string 'lucy     ' (length=9)
  5 => string '   ' (length=3)
  6 => string '    Lily' (length=8)
*/

 

posted @ 2018-01-15 10:19  sky20080101  阅读(161)  评论(0)    收藏  举报