2016-10-07 9 views
-2

私は段落のランダムな文字列から単語を探しています。3つの既知の単語から文字列を見つけるには?

<head> 
<style> 
    * {padding-top:10px; margin:0;} 
    body {overflow:hidden;} 
</style> 

<script src="http://content.jwplatform.com/libraries/V6NfEzT7.js"></script> 
    </head> 
    <center> <body> 
<div id="player"></div> 
    <script> 
     jwplayer('player').setup({ 
    sources: [{ 
     file: "rtmp://163.172.67.164:80/live", 
     file: "http://163.172.67.164/live/chsix/index.mp4?dsgfsdksdfbjdbfsdfsdkfs121413r" 
    }], 
    width: "60%", 
    aspectratio: "16:9", 
    hlshtml: true 
    }); 
</script> 
    <!-- Histats.com (div with counter) --><div id="histats_counter"></div> 
    <!-- Histats.com START (aync)--> 
    <script type="text/javascript">var _Hasync= _Hasync|| []; 
    _Hasync.push(['Histats.startgif', '1,3597882,4,10045,"div#histatsC {position: absolute;top:0px;left:0px;}body>div#histatsC {position: fixed;}"']); 
    _Hasync.push(['Histats.fasi', '1']); 
    _Hasync.push(['Histats.track_hits', '']); 
    (function() { 
    var hs = document.createElement('script'); hs.type = 'text/javascript';  hs.async = true; 
hs.src = ('//s10.histats.com/js15_gif_as.js'); 
(document.getElementsByTagName('head')[0] ||  document.getElementsByTagName('body')[0]).appendChild(hs); 
})();</script> 
<noscript><a href="/" alt="" target="_blank" ><div id="histatsC"><img border="0" src="http://s4is.histats.com/stats/i/3597882.gif?3597882&103"></div></a> 

私は "http://163.172.67.164/live/chsix/index.mp4?dsgfsdksdfbjdbfsdfsdkfs121413r" を見つけたいです。 既知のユニークワードは「mp4」です。 "mp4"の位置を見つけて、二重引用符の位置を前後に見つけることはできますか?出来ますか?

$html_encoded = htmlentities($text); 

    $pos = strpos($html_encoded, ".mp4"); 
    $pos1 = strpos($html_encoded, '"'); 

    echo substr($html_encoded,$pos-50,100)."<br>"; 

しかし、全体の二重引用符で囲まれた文を見つけることは無意味です:

私の少しの努力です。親切に私にそれを解決するように提案してください。

+0

がしますか? – brad

+0

この行を印刷したい場合 - 「http://163.172.67.164/live/chsix/index.mp4?dsgfsdksdfbjdbfsdfsdkfs121413r」 –

+0

あなたが言及している「文字列段落」の例を投稿することを検討してください。 – Craig

答えて

0

これはうまくいくはずです...埋め込まれたコメントを見てください。 $ zはあなたの望む文字列 "163.172.167.164/live/chsix/"を返します。

$x = "http://163.172.67.164/live/chsix/index.mp4?dsgfsdksdfbjdbfsdfsdkfs121413r"; 
$y = parse_url($x);      //create associative array that can be manipulated$y_exploded = explode('/', $y['path']); //break the path into an array 
array_pop($y_exploded);     //remove index.mp4 
$y_imploded = implode('/', $y_exploded); //glue the path back together 
$z = $y['host'].$y_imploded.'/'; 
+0

いいえ、そうではありません。私は段落から "http://163.172.67.164/live/chsix/index.mp4?dsgfsdksdfbjdbfsdfsdkfs121413r"という行全体を出力したいと思います。既知の単語は、文字列全体で.mp4であり、konwnという単語 "mp4"を含む2つの引用符の間にあります。 –

+0

「段落」とは何ですか?あなたがその文字列を投稿するのに役立ちます。 – Craig

0

これを試してみてください:正確にあなたが出力したいん何

<?php 
    $link = "http://163.172.67.164/live/chsix/index.mp4?dsgfsdksdfbjdbfsdfsdkfs121413r"; 
    // Break string on ".mp4" using explode 
    $break_first = explode(".mp4", $link); 
    // find last slash(/) position from above string 
    $last_slash = strrpos($break_first[0],'/'); 
    $result = substr($break_first[0], 0, $last_slash); 
?> 
関連する問題