[Resolvido] Função substr cortando em lugar errado (urgente)
Bom dia a todos , agradeço a ajuda , tenho um problema estou recebendo um site externo via CURL , ate ai tudo bem , o problema é que recebo em uma string que preciso formatar e ao usar o SUBSTR para formatar ele esta recortando o texto muito depois da posição correta, segue o codigo que estou usando :
class replace {
private $html;
private $header;
private $body;
function __construct($html) {
$this->html = $html;
}
function TagIniNum() {
$stringIni = addslashes('<head>');
$Ini = strpos($this->html, $stringIni);
return $Ini;
}
function TagFimNum(){
$stringFim = addslashes('</head>');
$Fim = strpos($this->html, $stringFim); // o corte esta ficando em lugar errado CORRIGIR
return $Fim;
}
function Corte() {
$TxtCort = mb_substr($this->html, $this->TagIniNum(), $this->TagFimNum());
echo $TxtCort;
}
}
e este é parte do conteudo da variavel $html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1; cache" />
<title>Consulta Débitos de Veículo</title>
<link href="/site/js/jQuery/css/estilo.css" rel="stylesheet" type="text/css" />
<link href="/site/js/jQuery/css/ui-lightness/jquery-ui-1.10.3.min.css" rel="stylesheet" type="text/css">
<script type="text/JavaScript" src="/site/js/jQuery/jquery-1.10.2.min.js"></script>
<script type="text/JavaScript" src="/site/js/jQuery/js/jquery-ui-1.10.3.min.js"></script>
<script type="text/JavaScript" src="./js/simpleCaptcha.js?ver=1.8"></script>
<script type="text/JavaScript" src="/site/js/captcha.js?ver=1.8"></script>
</head>
<body>
<form name="form" action="./consulta.php" method="post">
<div id="dialog" title=""></div>
Como quero recortar os texto contido entre as tag's header do html ele executa o recorte muitos caracteres apos a tag de fechamento, já tentei trabalhar diretamente com a variavel transformada com htmlentities e/ou usando o MB_SUBSTR e o resultado é o mesmo o corte sempre acontece muito apos a tag de final que é </header>.Discussão (6)
Carregando comentários...