为什么在childString中找不到originalString?
<?php
$originalString='<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hey, <br>
<br>
Here\'s the dump, email me the final version so I can write up the
email for the rest of the team. Feel free to review it and let me
know if you think I should change anything, I tried to keep it
simple and functional, but I\'m not a data guy like yourself. :P<br>
<br>
Thanks a ton!<br>
<div class="moz-signature">-- <br>
<span style="font-weight:heavy;font-style:italic;float:left;"><br>
Josh Someone<br>
Creative Developer<br>
<br>
Someplace Studios<br>
New Media Marketing Company<br>
<br>
<br>
Phone Number: 1-(555) 555-5555<br>
Website: <a class="moz-txt-link-freetext" href="http://www.someplace.com">http://www.someplace.com</a><br>
</span></div>
</body>
</html>
';
$childString = '<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 1/22/2013 5:05 PM,
<a class="moz-txt-link-abbreviated" href="mailto:jonathan@someplace.com">jonathan@someplace.com</a> wrote:<br>
</div>
<blockquote cite="mid:20130122170541.33321jbg8uoshnhx@someplace.com"
type="cite">Nothing was attached.
<br>
<br>
Quoting Josh Someone <a class="moz-txt-link-rfc2396E" href="mailto:josh@someplace.com"><josh@someplace.com></a>:
<br>
<br>
<blockquote type="cite">Hey,
<br>
<br>
Here\'s the dump, email me the final version so I can write up
the email for the rest of the team. Feel free to review it and
let me know if you think I should change anything, I tried to
keep it simple and functional, but I\'m not a data guy like
yourself. :P
<br>
<br>
Thanks a ton!
<br>
-- <br>
<br>
Josh Someone
<br>
Creative Developer
<br>
<br>
Someplace Studios
<br>
New Media Marketing Company
<br>
<br>
<br>
Phone Number: 1-(555) 555-5555
<br>
Website: <a class="moz-txt-link-freetext" href="http://www.someplace.com">http://www.someplace.com</a>
<br>
<br>
</blockquote>
<br>
<br>
<br>
</blockquote>
<br>
Bleh.<br>
<br>
<div class="moz-signature">-- <br>
<span style="font-weight:heavy;font-style:italic;float:left;"><br>
Josh Someone<br>
Creative Developer<br>
<br>
Someplace Studios<br>
New Media Marketing Company<br>
<br>
<br>
Phone Number: 1-(555) 555-5555<br>
Website: <a class="moz-txt-link-freetext" href="http://www.someplace.com">http://www.someplace.com</a><br>
</span></div>
</body>
</html>
';
$replace = array("\r\n"," ");
$originalText = str_replace($replace,'',strip_tags($originalString));
$childText = str_replace($replace,'',strip_tags($childString));
// $originalText = trim(str_replace(array('\r\n','\n','\r'),'',strip_tags($originalString)));
// $childText = trim(str_replace(array('\r\n','\n','\r'),'',(strip_tags($childString)));
if(stristr($childText,$originalText)){
echo "Yes";
} else {
echo "No";
}
答案 0 :(得分:1)
试试这段代码:
$replace = array("\r\n", " ");
$originalText = str_replace($replace,'',strip_tags($originalString));
$childText = str_replace($replace,'',strip_tags($childString));