Replacing text inside html tags using php curl -
Replacing text inside html tags using php curl -
i need replace appearances of vowels (a,e,i,o,u) on selected link vowel i. kind of internal joke (website translator app). far came this:
<?php if ($_get['sajt']!=null) { $url = str_replace('&', '&', $_get['sajt']); $ch = curl_init(); // set url , other options curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, 1); // page contents $html = curl_exec($ch); // close curl resource free scheme 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; } ?>
however, after this, str_replace changes html tags whole html page stored in same string (for illustration head hiid). searched can't figure out way propertly, require kind of html parsing , merging together
dirty way...
$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'; }
php html curl replace tags
Comments
Post a Comment