I'm trying to use the combo of $ and m modifier in preg_match_all.
preg_match_all('/.y$/m',$text,$matches);
basically I'm trying to get the last 2 letters of each line that ends with y, and this code works ok with this string.
$str2 = "helloly\nhelloby\nhelloty\n";
but when I try to use the same with data coming from a textarea element i only get the last line. same case is with heredoc and nowdoc. I want to understand how I can use regex with the m modifier on heredoc or multiline data from textarea
EDIT : this is the full code iam using for the test
the problem seems to be related to how newlines are interperted since when i changed the line seperator type in the php document heredoc/nowdocs are working fine. but post data still only matches the last line, I'll add the environment just incase Windows 10 x64 OSpanel 5.2.2 Apache 2.4-php7.0-7.1 PHP-7.1_64x
<?php
$str2 = "helloly\nhelloby\nhelloty\n";
$str = <<<HERE
helloly
helloby
helloty
HERE;
$text = $_POST['textarea2'];
$matches=[];
$pr =
var_dump(preg_match_all('/.y$/m',$str,$matches));
var_dump($matches);
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<form action="/" method="post">
<textarea name="textarea2" style="resize:none"></textarea>
<button type="submit">sub</button>
</form>
</body>
</html>