PHP 8.3.22 Released!

Voting

: three plus five?
(Example: nine)

The Note You're Voting On

b3forgames at gmail dot com
1 year ago
EXAMPLE:
$file = file_get_contents('file');
if(preg_match_all('#Task To Run(.*)#s', $file, $m)) {
var_dump($m);
}

No output...

preg_match_all not work if file exist BOM bytes (FF FE) :

╰─$ head -n1 file | hexdump -C
00000000 ff fe 48 00 6f 00 73 00 74 00 4e 00 61 00 6d 00 |..H.o.s.t.N.a.m.|

clear BOM via dos2unix:

╰─$ dos2unix file
dos2unix: converting UTF-16LE file file to UTF-8 Unix format...

Check again:

╰─$ head -n1 file | hexdump -C
00000000 48 6f 73 74 4e 61 6d 65 3a 20 20 20 20 20 20 20 |HostName: |

Great! Now preg_match_all works fine.

<< Back to user notes page

To Top