正则表达式和preg_replace

时间:2013-01-01 16:25:50

标签: regex preg-match

这一行是什么意思:

$fields = explode("\r\n", preg_replace('/\x0D\x0A[\x09\x20]+/', ' ', $header));

我从这个答案中得到了cURL , get redirect url to a variable

1 个答案:

答案 0 :(得分:1)

preg_replace将展开电子邮件header lines that are split across multiple lines。然后explode调用将结果字符串拆分为一个数组,每个数组单元有一个标题行。

例如,字符串:

Subject: This is a long subject
    line split across
  multiple lines
From: user@example.com

将由preg_replace转换为:

Subject: This is a long subject line split across multiple lines
From: user@example.com

以下explode会给您:

Array(
    [0] => 'Subject: This is a long subject line split across multiple lines',
    [1] => 'From: user@example.com'
)