scrapingに必要だったので作りました。短いので毎回書いていたのですが、あまりにも頻繁に使うのでメモがてら関数化しました。

function iterative_cutter($needle_start, $needle_end, $content)
{
  $start = 0;
  $results = array();
  while(true){
    $ret = strpos($content, $needle_start, $start);
    if($ret == false){
      return $results;
    }
    $start = $ret + strlen($needle_start);
    $end = strpos($content, $needle_end, $start);
    $line = substr($content, $start, $end - $start);
    $results[] = $line;
    $start = $end + strlen($needle_end);
  }
}

  添付編集
Last-modified: 2017-10-20 (金) 02:00:32 (2351d)