Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
| info:myphp:array [2026/03/05 08:45] – [3 dim array with limesurvey] radeff | info:myphp:array [2026/03/05 09:49] (Version actuelle) – radeff | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| - | ====== Arrays | + | ====== |
| + | ===== explode ===== | ||
| + | |||
| + | < | ||
| + | <?php | ||
| + | $pizza = " | ||
| + | $pieces = explode(" | ||
| + | |||
| + | |||
| + | for($i=0; | ||
| + | print(" | ||
| + | } | ||
| + | echo "< | ||
| + | show_source(" | ||
| + | ?> | ||
| + | </ | ||
| ===== 1 dimension ===== | ===== 1 dimension ===== | ||
| Ligne 31: | Ligne 46: | ||
| </ | </ | ||
| ===== 3 dim array with limesurvey ===== | ===== 3 dim array with limesurvey ===== | ||
| - | ====== | + | **Un script pour faire un loop sur 3 arrays php, avec du mysql** |
| - | + | exemple: renvoyer un message d' | |
| - | exemeple: ici pour renvoyer un message d' | + | |
| < | < | ||
| Ligne 135: | Ligne 149: | ||
| </ | </ | ||
| </ | </ | ||
| - | |||
| </ | </ | ||
| ===== n dimensions ===== | ===== n dimensions ===== | ||
| - | [[highlight_menu.inc.php]] | + | <code php> |
| - | ===== csv ===== | + | <?php |
| + | /* [[highlight_menu.inc.php]] | ||
| + | # | ||
| + | # Authors: | ||
| + | # FR, radeff@akademia.ch | ||
| + | # History | ||
| + | # 2006: FR, created; modified | ||
| + | ######### | ||
| + | */ | ||
| + | #affiche menus gauche (verticaux) | ||
| + | function lemenugauche() { | ||
| + | $cettePage= $_SERVER[' | ||
| + | $cettePage=ereg_replace(" | ||
| - | < | + | /* |
| - | <? | + | //here some stuf if you want the current directory |
| - | include("header.inc.php"); | + | $cetURL= $_SERVER["REQUEST_URI"]; |
| - | + | $cettePage=ereg_replace("^.*/","" | |
| - | $total=0; | + | $ceRep=ereg_replace("^.*/(.*)/$cettePage$"," |
| - | $myFile=fopen("array.csv"," | + | echo $cetURL; |
| - | while(!feof($myFile)) { | + | echo "<br>"; |
| - | | + | echo $ceRep; |
| - | $link="$data[1]"; | + | echo "< |
| - | $total+=$link; | + | echo $cettePage; |
| - | } | + | */ |
| - | fclose($myFile); | + | |
| ?> | ?> | ||
| - | + | <style type=" text/css "> | |
| - | <p class=titrerouge> | + | /* classe spéciale pour highlighter un item du menu */ |
| - | + | .active { | |
| - | < | + | color : #800000; |
| - | </ | + | |
| - | + | | |
| - | <table border=0> | + | } |
| + | </style> | ||
| <? | <? | ||
| - | echo "<tr BGCOLOR=yellow>< | + | $menu=array( |
| - | # | + | " |
| - | $i=1; | + | " |
| - | $myFile=fopen("array.csv","r"); | + | " |
| - | | + | "Liens" |
| - | | + | ); |
| - | | + | foreach($menu as $libelle_lien=> |
| - | $link="$data[1]"; | + | |
| - | $texte="$data[0]"; | + | if(ereg($cettePage,$url) && strlen($cettePage)!=0) { //on met en valeur la page dans les menus SAUF pour la homepage |
| - | $pc=intval(100*($link/ | + | $classemenuDeb="<span class=\" |
| - | if (intval($i/2)==($i/2)) { | + | $classemenuFin="</span"; |
| - | echo "<tr BGCOLOR='# | + | } else { |
| - | } else { | + | $classemenuDeb="" |
| - | echo "< | + | $classemenuFin=""; |
| + | } | ||
| + | echo "< | ||
| + | } | ||
| } | } | ||
| + | lemenugauche(); | ||
| + | #fin menus gauche | ||
| + | ?> | ||
| + | </ | ||
| - | echo "< | + | ===== array_splitter ===== |
| - | $i++; | + | <code> |
| - | } | + | <? |
| - | fclose($myFile); | + | function array_splitter($delimiter, |
| + | { | ||
| + | $array = explode($delimiter, | ||
| - | echo "< | + | #returns the number of elements in the array |
| + | $size=count($array); | ||
| + | |||
| + | for ($i=0; $i <= $size; $i++) | ||
| + | echo $array[$i] . "<BR>"; | ||
| + | |||
| + | } | ||
| + | #Laurent Gottardo, 15.9.04 | ||
| + | ?> | ||
| - | include(" | ||
| - | ?> | ||
| </ | </ | ||