Convertir du code PHP en JavaScript
Posté : 23 févr. 2017, 00:29
Bonjour,
J'ai besoin de convertir du code PHP en JavaScript mais je ne maitrise rien ...
voici le code a convertir :
Une âme charitable pour m'aiguiller ? car la je nage dans le sable ...
Merci
J'ai besoin de convertir du code PHP en JavaScript mais je ne maitrise rien ...
voici le code a convertir :
Code : Tout sélectionner
<?php
$string = file_get_contents('route.html');
$pattrn = "/updi\(event\,\'(.*)'\)/m";
preg_match_all($pattrn,$string,$array);
$arrResultat = array();
foreach($array[1] as $value) {
$str2 = str_replace("<br>Distances: " ,"|",$value);
$str2 = str_replace("<br><b>Wind:</b>" ,"|",$str2);
$str2 = str_replace("(<b>TWA" ,"|",$str2);
$str2 = str_replace("</b>)<br><b>Heading:</b>" ,"|",$str2);
$str2 = str_replace("<b>Sail:</b>" ,"|",$str2);
$str2 = str_replace("<br><b>Boat Speed:</b>" ,"|",$str2);
$str2 = str_replace("','" ,"|",$str2);
$arrResultat[] = $str2;
}?>
<table border="1">
<tr>
<td>Date et Heure</td><td>Distances</td><td>Wind</td><td>TWA</td><td>HDG</td><td>Sail</td><td>Boat Speed</td>
</tr><?php
foreach($arrResultat as $value) {
$arrInfo = explode('|',$value);
$TWA = (int) $arrInfo[3];
$color = $TWA >= 0 ? 'green' : 'red';?>
<tr>
<td><?php print $arrInfo[0];?></td>
<td><?php print $arrInfo[1];?></td>
<td><?php print $arrInfo[2];?></td>
<td style="color:<?php print $color;?>"><?php print abs($TWA);?></td>
<td><?php print $arrInfo[4];?></td>
<td><?php print $arrInfo[5];?></td>
<td><?php print $arrInfo[6];?></td>
</tr><?php
}?>
</table>
Merci