函數範例:
function ReplaceWrap(& $str)
{
if (strpos($str, "\"")!== false){
$s = substr($str, strpos($str, "\"")+1);
$e = substr($s, 0, strpos($s, "\""));
$done = str_replace("\n", " ", $e);
$str = str_replace("\"".$e."\"", $done, $str);
ReplaceWrap($str);
}
}
使用範例:
$str = "王大明 \"1.上課都遲到
2.常常忘記帶便當\"
陳大郎 模範生";
ReplaceWrap($str);
$str = explode("\n", $str);
print_r($str);
輸出結果:
Array ( [0] => 王大明 1.上課都遲到 2.常常忘記帶便當 [1] => 陳大郎 模範生 )