Skip to content

Instantly share code, notes, and snippets.

@narita1980
Created March 12, 2013 08:06
Show Gist options
  • Save narita1980/5141046 to your computer and use it in GitHub Desktop.
Save narita1980/5141046 to your computer and use it in GitHub Desktop.
HTMLファイル内のimgタグを抽出する ■使用例 $ php exp_imgtag.php < sample.html <img alt="・・・・ /> <img border="・・・ /> ・・・
<?php
$stdin = file_get_contents('php://stdin', 'rb');
preg_match_all('@<img .*?/>@isu' ,$stdin ,$regex, PREG_SET_ORDER);
foreach ($regex as $str) {
echo $str[0] . PHP_EOL;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment