Concatener deux noms variables

Résolu
cseagle Messages postés 99 Date d'inscription vendredi 18 avril 2003 Statut Membre Dernière intervention 5 août 2009 - 26 juil. 2005 à 13:24
 Julie - 15 avril 2021 à 01:07
Bonjour tout le monde,



J'ai besoin d'une petite aide.



Voila je désire concatener ma variable $tab avec $val de manière à
obtenir ceci : $tab1 ou $tab2 .... donc en fait rajouter la valeur de
$val à la fin du nom de la variable $tab.



j'ai essayé $tab.$val ''; et $tab."$val" ''; mais ca ne marche pas.



Comment dois je faire ?



Merci d'avance ;-)
A voir également:

24 réponses

malalam Messages postés 10839 Date d'inscription lundi 24 février 2003 Statut Membre Dernière intervention 2 mars 2010 25
Modifié le 15 avril 2021 à 10:12
FhX => Je l'avais meme pas vue lol. Quel con...bah oui t'as
raison, y a une petite lecture a faire faire a cseagle sur la portee
des variables en php.
0
malalam Messages postés 10839 Date d'inscription lundi 24 février 2003 Statut Membre Dernière intervention 2 mars 2010 25
28 juil. 2005 à 09:08
GRenard => effectivement :

http://www.garret.ru/~knizhnik/cppreflection/docs/reflect.html

Introduction



Reflection is a mechanism making it possible to investigate yourself.
If we are speaking about programming languages, reflection is used
to investigate format of objects at runtime, invoke methods and access fields
of these objects. Reflection is required if you want to implement some generic code
which can work with objects of unknown (at the time of creation of this code) types.
There are several tasks in which reflection can be used:
remote method invocation, serialization, object dumps, database interfaces.
How it works? Given some object we first should ask for its
type
.
As a result we are given class descriptor, which provides information about class methods and
fields. We can use these field descriptors to fetch/store object fields and can use
method descriptors to lookup and invoke methods.


Many programming languages provide built-in reflection mechanism. For example, in Java
there is special package
java.lang.reflect
. But unfortunately C++
doesn't support reflection. Not so long ago first step was made in this direction -
RTTI support was added to the language. But RTTI provides only very restricted subset of reflection:
it allows to get object compile-time and runtime type (it is possible to get object runtime type
only if object class contains virtual functions). You can compare types and you can get type name -
and that is all you can do with RTTI.




There are several ways of extracting type information for C++:
0
cseagle Messages postés 99 Date d'inscription vendredi 18 avril 2003 Statut Membre Dernière intervention 5 août 2009
28 juil. 2005 à 11:51
Je l'avais enlevée la fonction, c'est qu'au début je voulais tout gérer dedans ;-)
0
J'ai fait un association de 3 variables pour créer un nom de variable ;-)
${"metadata_185_[$i]_$j"}


pour ceci
    for ($i = 1; $i <= 10; $i++) {
for ($j = 1; $j <= 5; $j++) {
${"metadata_185_[$i]_$j"} = get_post_meta( $post->ID, 'metadata_185_'.$i.'_'.$j.'', true );
}
}


je voulais arriver à $metada_185_1_1 (et encore le 185 est en dur ;)
0
Rejoignez-nous