2013-07-24 1 views
0

왜 originalString이 childString에서 발견되지 않습니까?Stristr 건초 더미에서 바늘을 찾지 못함

<?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:[email protected]">[email protected]</a> wrote:<br> 
    </div> 
    <blockquote cite="mid:[email protected]" 
    type="cite">Nothing was attached. 
    <br> 
    <br> 
    Quoting Josh Someone <a class="moz-txt-link-rfc2396E" href="mailto:[email protected]">&lt;[email protected]&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("\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

'위해서 var_dump ($ originalText, $ childString가)'--- – zerkms

+0

문자열 (25) 문자열 (62) "안녕 버디"추측 중지 "이봐 수 버디 두 " – jkushner

+0

Youve는 그것을 뒤로 얻었다. 당신이 출력물에'\ n'을 놓친 것입니다 .123 char 문자열을 25 자 문자열로 검색했습니다. – jkushner

답변

1

이 코드를보십시오 :

$replace = array("\r\n", " "); 

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

http://pastebin.com/VxXiYjEG – jkushner

+0

업데이트 된 질문 – jkushner

+0

"& nbsp"삭제가 필요합니까? 및 < > ... 등 로 변경 $ replace = array ("\ r \ n", "", " "); – Akira

관련 문제