M.O.S. Studios Posted January 4, 2011 Share Posted January 4, 2011 I have loaded an external html file into a var using fopen() and fread(). I'm trying to get a value that relates the the character after the <head> tag. I'm trying to compensate for any white space or attributes that might be added to it. I'm also trying to avoid a false result from any JavaScript that might be in the file. as of right now im using $template = fopen($template_dir, 'r'); $template = fread($template, filesize($template_dir)); $head_pos = stripos($template, '>', stripos($template, 'head', stripos($template, 'html', stripos($template, '<'))))+1 I'm sure there is a more effective way to do this possibly with regex. any ideas. thanks in advance Link to comment https://forums.phpfreaks.com/topic/223328-finding-tag-in-an-external-file/ Share on other sites More sharing options...
requinix Posted January 4, 2011 Share Posted January 4, 2011 I'm also trying to avoid a false result from any JavaScript that might be in the file. Good luck with that. <br /> document.write("<head><title>Title<\/title><\/head>");<br /> Works in every browser I know Link to comment https://forums.phpfreaks.com/topic/223328-finding-tag-in-an-external-file/#findComment-1154520 Share on other sites More sharing options...
M.O.S. Studios Posted January 4, 2011 Author Share Posted January 4, 2011 I know how to do document.write() I have html files that i want to scan, so for example <html lang="en"> <head>* <title><!-- Insert your title here --></title> </head> <body> <?php echo md5($_POST['str'], $_POST['sixteenbit']); ?> <br> <?= strlen(md5($_POST['str'], $_POST['sixteenbit'])); ?> <form method='post'> <input type='text' name='str' value='<?= $_POST['str']; ?>'> <input value='true' name='sixteenbit' type='checkbox'> <input type='submit'> </form> <!-- Insert your content here --> </body> </html> the result I want is 23 (located with a star) Link to comment https://forums.phpfreaks.com/topic/223328-finding-tag-in-an-external-file/#findComment-1154521 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.