Jump to content

preg_match


firedealer

Recommended Posts

I know $regex_pattern is wrong but I need a solution to find a content between <body> and </body>.

 

<?php
$content = "<html><head><title>Your IP</title></head><body>Your IP Address: 63.1.142.154</body></html>";
$regex_pattern = "/<body>(.*)<\/body>/";
$preg_match($regex_pattern,htmlspecialchars($content),$matches);
print_r( $matches );
?>

Link to comment
https://forums.phpfreaks.com/topic/235971-preg_match/
Share on other sites

Thanks. I have update my code and still not working.

 

ERROR MSG:

 

Notice: Undefined variable: preg_match in /Applications/MAMP/htdocs/include/ip.php on line 6

 

Fatal error: Function name must be a string in /Applications/MAMP/htdocs/include/ip.php on line 6

Link to comment
https://forums.phpfreaks.com/topic/235971-preg_match/#findComment-1213145
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.