<?php $texte=$_POST['Req']; $TGras=array(); preg_match_all("#<B>T(.)*?T</B>#",$texte,$TGras); print_r($TGras[0]); echo "<hr>"; $texte=preg_replace('/[,\.]/','',$texte); $texte=trim($texte); $tableau=preg_split("/( )+/",$texte); echo $texte."<br>"; print_r($tableau."<br>"); $T=array(); $T2=array(); $total=count($tableau); foreach($tableau as $e){ if(!key_exists($e,$T)) { $T[$e]=1; }else{ $T[$e]++; } } $M=sizeof($tableau)/2; for($i=0;$i<sizeof($tableau);$i++){ if(!key_exists($tableau[$i],$T2)) { $T2[$tableau[$i]]=($i+1-$M)*($i+1-$M); }else{ $T2[$tableau[$i]]=$T2[$tableau[$i]]+($i+1-$M)*($i+1-$M); } } print_r($T); print_r($T2); echo "<Table border=1>"; echo "<tr><th>Mot</th><th>nbr occurences</th><th>distribution</th></tr>"; foreach(array_keys($T) as $e){ echo "<tr><td>$e</td><td>".round($T[$e]*100/$total,2)." %</td><td>".sqrt($T2[$e])."</td></tr>"; } echo "</table>"; ?>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)