0
I have a text written in <TextArea>
on a page html and liked in php read the text and remove a piece of it and write in another <TextArea>
, tried to use the preg_match
but I couldn’t quite understand how it works, 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
ALL?
I need to read whatever’s 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
https://answall.com/questions/163557/pegar-o-texto-entre-uma-tag/163561#163561
– MagicHat
@Magichat already tested the answer was blank
– Tmc
As you have tested?
– MagicHat
@Magichat does not work because if you have more tags will show all.
– Tmc