使用php curl替换html标记中的文本

使用php curl替换html标记中的文本,php,html,curl,replace,tags,Php,Html,Curl,Replace,Tags,我需要用元音I替换以前选择的链接上的所有元音(a、e、I、o、u)。这是一种内部笑话(网站翻译应用程序)。到目前为止,我得出了以下结论: <?php if ($_GET['sajt']!=NULL) { $url = str_replace('&', '&amp;', $_GET['sajt']); $ch = curl_init(); // Set url and other options curl_setopt

我需要用元音I替换以前选择的链接上的所有元音(a、e、I、o、u)。这是一种内部笑话(网站翻译应用程序)。到目前为止,我得出了以下结论:

    <?php
    if ($_GET['sajt']!=NULL)
    {
    $url = str_replace('&', '&amp;', $_GET['sajt']);
    $ch = curl_init(); 
    // Set url and other options
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    // Get the page contents
    $html = curl_exec($ch); 

    // close curl resource to free up system resources 
    curl_close($ch);  
    $vowels = array("a", "e", "i", "o", "u");
    $onlyconsonants = str_replace($vowels, "i", $html);
    $vowels = array("A", "E", "I", "O", "U");
    $onlyconsonants = str_replace($vowels, "I", $onlyconsonants);
    echo $onlyconsonants;
    }
    ?>

但是,在我这样做之后,str_replace也会更改html标记,因为整个html页面都存储在同一个字符串中(例如head to hiid)。我搜索过,但我无法找到正确的方法,因为这需要某种html解析,然后将其合并到一起

    $strlen = strlen( $html);
    $id = "";
    for( $i = 0; $i <= $strlen; $i++ ) {
    if ($html[$i]=='<' || $html[$i]=='>') $id = $html[$i];
    if (($html[$i]=='a' || $html[$i]=='e' || $html[$i]=='o' || $html[$i]=='u') && ($id=='>')) $html[$i] = 'i';
    if (($html[$i]=='A' || $html[$i]=='E' || $html[$i]=='O' || $html[$i]=='U') && ($id=='>')) $html[$i] = 'I';
    }
$strlen=strlen($html);
$id=“”;
对于($i=0;$i)