I have a text written in a <TextArea>
on a html page and would like to read the text and remove a piece of it and write in another <TextArea>
, I tried to use preg_match
but I could not understand how it worked, let's go to data.
Text:
<html>
<head>
<title>Teste</title>
</head>
<body>
<h1> Hello World </h1>
<h2> está </h2>
<h1> TUDO? </h1>
</body>
</html>
Answer:
Hello World
EVERYTHING?
I need to read whatever is between <h1>
and </h1>
.
Code:
<textarea name="resultcode" cols="130" rows="30" wrap="OFF">
<?php
$html = $_POST['htmlcode'];
echo preg_match_all('/<h1>(.*)</h1>(.*)/i',$html, $matches);
var_dump($matches);
?>
</textarea>
ERROR:
<br /> <b>Warning</b>: preg_match_all(): Unknown modifier 'h' in <b>/home/u982560592/public_html/index.php</b> on line <b>19</b><br /> NULL