我有一个带有以下格式的换行符和空格的字符串。
<?php
$str = 'Name: XXXXXXXX
Email: XXXX@sample.com
Community: Test Community.';
?>
我想将此字符串转换为数组
Array(
[Name] => XXXXXXXX
[Email]=> XXXX@sample.com
[Community] => Test Community.
)
我的尝试:
$str = 'Name: XXXXXXXX Email: XXXX@sample.com Community: Test Community.';
echo "<pre>";
print_r(explode(":", $str));
exit;
侃侃尔雅
眼眸繁星
蝴蝶不菲