Jump to content

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)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.