2016-12-07 65 views
-5

我需要将我的字符串输入拆分为如下所示的分号。如何将分号分隔的字符串拆分为字符串中的单独项目?

Original String: Loganathan <[email protected]>; Nathan <[email protected]>; Tester <[email protected]>; 

我需要拆分喜欢

Loganathan, [email protected] 
Nathan, [email protected] 
Tester, [email protected] 

我如何去实现呢?

+2

使用'Explode' http://php.net/manual/en/function.explode.php –

+0

发布您的工作。 – akshay

回答

1

您可以使用explode函数。 explode link

$str = "Loganathan <[email protected]>; Nathan <[email protected]>; Tester <[email protected]>;"; 
$str = str_replace(array(" <",">"),array(", ",""),$str); 
$converted = explode(";",$str); 
print_r($converted); 

其中给出像

Array(
    [0] => Loganathan, [email protected] 
    [1] => Nathan, [email protected] 
    [2] => Tester, [email protected] 
) 
+0

对我来说,不会显示电子邮件 – logudotcom

+0

由于'<' & '>',浏览器认为这是一个html标记,因此当您在浏览器中看到源代码时,您可以看到并显示在浏览器中,您必须将其替换为空白@logudotcom –

+0

好的,谢谢,明白了 – logudotcom

相关问题