Jump to content

Finding <head> tag in an external file


M.O.S. Studios

Recommended Posts

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

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)

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.