Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Last active February 6, 2016 12:45
Show Gist options
  • Save kurozumi/c2e37e9f6e5ff7b4e174 to your computer and use it in GitHub Desktop.
Save kurozumi/c2e37e9f6e5ff7b4e174 to your computer and use it in GitHub Desktop.
【PHP】RegexIteratorクラスを使ってファイル内の数字の行だけ取得する方法
<?php
$file = new RegexIterator(new SplFileObject("sample.txt", "r"), '/^\d*$/');
foreach($file as $line)
{
var_dump($line);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment