info:myphp:array

Ceci est une ancienne révision du document !


Arrays en php

<?php
/* [[simplearray1dimension.php]] Script to highlight dynamically navigation link corresponding to the current page
#
# Authors:
# FR, radeff@akademia.ch
# History
# 2008/01/23 10:11: FR, created
#########
$array=array(
'nom',
'prenom',
'adresse',
'cp',
'ville',
'email',
'mobile'
);

$size=count($array);

	for ($i=0; $i <= $size; $i++) {
	echo $array[$i] . "<BR>";


}
?>

highlight_menu.inc.php ex. array simple 2 dimensions

<?
include("header.inc.php");

$total=0;
$myFile=fopen("array.csv","r");
    while(!feof($myFile)) {
        $data=fgetcsv($myFile,100,';');
    $link="$data[1]";
$total+=$link;
        }
fclose($myFile);

?>

<p class=titrerouge>Analyse bàl webmaster@unige.ch</p>

<table><tr><td class=titrenoir>&nbsp;9.7.03&nbsp;</td></tr>
</table>

<table border=0>
<?
echo "<tr BGCOLOR=yellow><td>Libellé</td><td align=right>Hits</td><td align=right>%</td></tr>";
#$total=0;
$i=1;
$myFile=fopen("array.csv","r");
    while(!feof($myFile)) {
        $data=fgetcsv($myFile,100,';');
        $num=count($data);
    $link="$data[1]";
$texte="$data[0]";
    $pc=intval(100*($link/$total));
if (intval($i/2)==($i/2)) {
echo "<tr BGCOLOR='#EEEEEE'>";
} else {
echo "<tr BGCOLOR='#FFFFFF'>";
}

    echo "<td align=left>$texte</td><td align=right>$link</td><td align=right>$pc</td></tr>\n";
$i++;
        }
fclose($myFile);


echo "<tr BGCOLOR=yellow><td>Total</td><td align=right>$total</td><td>100 %</td></tr></table>";

include("footer.inc.php");
?> 
  • info/myphp/array.1772696724.txt.gz
  • Dernière modification : 2026/03/05 08:45
  • de radeff