explode函数分割,求助

WBOY
Release: 2016-06-23 14:02:04
Original
983 people have browsed it

$str = "爸爸,妈妈,奶奶;爷爷.外公,外伯,舅舅";
$net = explode(',',$str);

如何将分害成
1=>爸爸
2=>妈妈
3=>奶奶
4=>爷爷
5=>外公
6=>外伯
7=>舅舅


回复讨论(解决方案)

$str = "爸爸,妈妈,奶奶;爷爷.外公,外伯,舅舅";$str = str_replace(';', ',', $str);$str = str_replace('.', ',', $str);$net = explode(',',$str);var_dump($net);
Copy after login

$net = preg_split('/[,;.]/',$str);print_r($net);
Copy after login

Array
(
    [0] => 爸爸
    [1] => 妈妈
    [2] => 奶奶
    [3] => 爷爷
    [4] => 外公
    [5] => 外伯
    [6] => 舅舅
)

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!