écriture résultat

Résolu/Fermé
t671 Messages postés 1429 Date d'inscription lundi 25 février 2008 Statut Membre Dernière intervention 27 septembre 2024 - 6 avril 2015 à 10:52
t671 Messages postés 1429 Date d'inscription lundi 25 février 2008 Statut Membre Dernière intervention 27 septembre 2024 - 6 avril 2015 à 14:47
Bonjour,

Dans mon script, voici ce que j'écris :
echo $generation;
echo '-';
echo $num;
echo '/';
echo $nb_indiv;

et c'est pour avoir comme résultat : 2-1/8

Comment écrire mon code sur une ligne (et non 4) ?
Avec les ponctuations j'ai du mal ............ :o(
Merci
A voir également:

3 réponses

NHenry Messages postés 15156 Date d'inscription vendredi 14 mars 2003 Statut Modérateur Dernière intervention 29 septembre 2024 334
6 avril 2015 à 12:47
Sur 4 lignes ?
J'en vois 5 là ...

2 solutions :
echo  $generation.'-'.$num.'/'.$nb_indiv;
printf('%d-%d/%d',$generation,$num,$nb_indiv);

0
bonobo47 Messages postés 142 Date d'inscription samedi 19 janvier 2013 Statut Membre Dernière intervention 14 août 2017 13
6 avril 2015 à 14:26
Plus simplement :

echo $generation; echo '-'; echo $num; echo '/'; echo $nb_indiv;


0
t671 Messages postés 1429 Date d'inscription lundi 25 février 2008 Statut Membre Dernière intervention 27 septembre 2024 11
6 avril 2015 à 14:47
Merci pour ta réponse NHenry ! Effectivement, y'a 5 lignes ........
Pour bonobo47 : effectivement c'est une solution .......... mais j'attendais plutôt celle de NHenry.
0