1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
$pattern = "/\>[[:alnum:]' '\[\]\*\=\+\%\"\'\(\)|{\}\.\,\:\!\§].+?\</";
preg_match_all($pattern, $stringHtml, $matches);
$matches = $matches[0];
//On supprime les < et >
for($i =0; $i<count($matches); $i++){
if(is_empty(trim(str_replace(' ', '', $matches[$i])))){
unset($matches[$i]);
}else{
$matches[$i] = substr($matches[$i], 1, -1);
}
}
$matches = array_values($matches);
$trad = new BingTraduction();
foreach($matches as $key => $tag) {
$stringHtml = str_replace($tag, $trad->translate($tag, 'en', 'fr'), $stringHtml );
} |
Partager