如何把下面的字符串:<姓名>name<手機(jī)號(hào)碼>12345678910<郵箱>123456@foxmail.com....;拆分成:[姓名 => name, 手機(jī)號(hào)碼 => 12345678910, 郵箱 => 123456@foxmail.com, ....]
1 回答

半路出家小和尚
TA貢獻(xiàn)1條經(jīng)驗(yàn) 獲得超2個(gè)贊
我暫時(shí)找到這種不用foreach的方法:
<?php
$customer = "<姓名>name<手機(jī)號(hào)碼>12345678910<郵箱>123456@foxmail.com";
$customer = str_replace('>', '=', $customer);
$customer = str_replace('<', '&', $customer);
parse_str($customer, $customerArr);
print_r($customerArr);
?>
不知道這種方法有沒有什么弊端,哪位大神來指教下
- 1 回答
- 0 關(guān)注
- 2002 瀏覽
添加回答
舉報(bào)
0/150
提交
取消