【发布时间】:2023-04-04 07:25:01
【问题描述】:
【问题讨论】:
-
@GabrielSantos 好点。欢迎迈克尔!
标签: php arrays split explode delimiter
【问题讨论】:
标签: php arrays split explode delimiter
既然你已经用php 标记了你的问题,我会坚持下去。请参阅preg_split
$split_strings = preg_split('/[\ \n\,]+/', $your_string);
这也将保持数组干净,如果您的字符串类似于some, ,,string,它仍然会导致['some', 'string'] 而不是['some', '', '', '', 'string']。
【讨论】:
hey 'this is' some text 产生 ['hey', 'this is', 'some', 'text']?
PREG_SPLIT_NO_EMPTY,所以它就像preg_split('/[\ \n\r\,]+/', $your_string, -1, PREG_SPLIT_NO_EMPTY);,如:php.net/manual/en/function.preg-split.php
explode(' ', $my_string)?