質問編集履歴

1

完全版のコードを加筆しました

2021/09/10 08:50

投稿

pegy
pegy

スコア243

test CHANGED
File without changes
test CHANGED
@@ -35,3 +35,35 @@
35
35
 
36
36
 
37
37
  改行等のパターン修飾子も付してみたのですが、どうしても変数代入から取得できず、なぜこのような現象がおきるのかわからず、ご助言と解決方法をご教示いただきたく、お願い申し上げます。
38
+
39
+
40
+
41
+ 【追記】完全版のコード
42
+
43
+ [利用ライブラリ](https://packagist.org/packages/spatie/pdf-to-text)([他参考にしたもの](https://pgmemo.tokyo/data/archives/1636.html))
44
+
45
+ php ver:7.4.1
46
+
47
+ ```php
48
+
49
+ // ini_set('display_errors', "On");
50
+
51
+ use Spatie\PdfToText\Pdf;
52
+
53
+ require_once __DIR__ . '/vendor/autoload.php';
54
+
55
+
56
+
57
+ $parser = new \Smalot\PdfParser\Parser();
58
+
59
+ $pdf = $parser->parseFile('https://www.jbatibor.or.jp/rate/pdf/JAPANESEYENTIBOR210831.pdf');
60
+
61
+ $get_contents = $pdf->getText();
62
+
63
+ var_dump($get_contents); //正しく出力
64
+
65
+ preg_match("@2021/08/31 (.+?) 2.../@",$get_contents,$res);
66
+
67
+ var_dump($res); //array(0){}
68
+
69
+ ```