duan5801 2013-07-24 01:39
浏览 13
已采纳

Stristr没有在干草堆中找到针

Why is the originalString not being found in the childString?

<?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">&lt;josh@someplace.com&gt;</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>
    --&nbsp;<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("
"," ");

 $originalText = str_replace($replace,'',strip_tags($originalString));
 $childText    = str_replace($replace,'',strip_tags($childString));

  // $originalText =    trim(str_replace(array('
','
',''),'',strip_tags($originalString)));
  // $childText    = trim(str_replace(array('
','
',''),'',(strip_tags($childString)));

 if(stristr($childText,$originalText)){
         echo "Yes";
  } else {
         echo "No";
 }
  • 写回答

1条回答 默认 最新

  • dongshi1868 2013-07-24 02:01
    关注

    Try this code:

    $replace = array("
    ", " ");
    
    $originalText = str_replace($replace,'',strip_tags($originalString));
    $childText    = str_replace($replace,'',strip_tags($childString));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥30 求解达问题(有红包)